Merge branch 'prototype/graphql/ariadne' into #162
# Conflicts: # kdb-bot/cpl-workspace.json # kdb-bot/src/bot/config # kdb-bot/src/bot/module_list.py # kdb-bot/src/bot_api/api.py # kdb-bot/src/bot_data/service/client_repository_service.py # kdb-bot/src/bot_data/service/server_repository_service.py
This commit is contained in:
@@ -28,19 +28,19 @@ class ClientRepositoryService(ClientRepositoryABC):
|
||||
self._logger.trace(__name__, f"Send SQL command: {Client.get_select_all_string()}")
|
||||
results = self._context.select(Client.get_select_all_string())
|
||||
for result in results:
|
||||
self._logger.trace(__name__, f"Get client with id {result[0]}")
|
||||
clients.append(
|
||||
Client(
|
||||
result[1],
|
||||
result[2],
|
||||
result[3],
|
||||
result[4],
|
||||
result[5],
|
||||
result[6],
|
||||
self._servers.get_server_by_id(result[7]),
|
||||
id=result[0],
|
||||
)
|
||||
)
|
||||
self._logger.trace(__name__, f'Get client with id {result[0]}')
|
||||
clients.append(Client(
|
||||
result[1],
|
||||
result[2],
|
||||
result[3],
|
||||
result[4],
|
||||
result[5],
|
||||
result[6],
|
||||
self._servers.get_server_by_id(result[7]),
|
||||
result[8],
|
||||
result[9],
|
||||
id=result[0]
|
||||
))
|
||||
|
||||
return clients
|
||||
|
||||
@@ -55,7 +55,9 @@ class ClientRepositoryService(ClientRepositoryABC):
|
||||
result[5],
|
||||
result[6],
|
||||
self._servers.get_server_by_id(result[7]),
|
||||
id=result[0],
|
||||
result[8],
|
||||
result[9],
|
||||
id=result[0]
|
||||
)
|
||||
|
||||
def get_client_by_discord_id(self, discord_id: int) -> Client:
|
||||
@@ -72,7 +74,9 @@ class ClientRepositoryService(ClientRepositoryABC):
|
||||
result[5],
|
||||
result[6],
|
||||
self._servers.get_server_by_id(result[7]),
|
||||
id=result[0],
|
||||
result[8],
|
||||
result[9],
|
||||
id=result[0]
|
||||
)
|
||||
|
||||
def find_client_by_discord_id(self, discord_id: int) -> Optional[Client]:
|
||||
@@ -83,9 +87,9 @@ class ClientRepositoryService(ClientRepositoryABC):
|
||||
result = self._context.select(Client.get_select_by_discord_id_string(discord_id))
|
||||
if result is None or len(result) == 0:
|
||||
return None
|
||||
|
||||
|
||||
result = result[0]
|
||||
|
||||
|
||||
return Client(
|
||||
result[1],
|
||||
result[2],
|
||||
@@ -94,7 +98,9 @@ class ClientRepositoryService(ClientRepositoryABC):
|
||||
result[5],
|
||||
result[6],
|
||||
self._servers.get_server_by_id(result[7]),
|
||||
id=result[0],
|
||||
result[8],
|
||||
result[9],
|
||||
id=result[0]
|
||||
)
|
||||
|
||||
def find_client_by_server_id(self, discord_id: int) -> Optional[Client]:
|
||||
@@ -105,9 +111,9 @@ class ClientRepositoryService(ClientRepositoryABC):
|
||||
result = self._context.select(Client.get_select_by_server_id_string(discord_id))
|
||||
if result is None or len(result) == 0:
|
||||
return None
|
||||
|
||||
|
||||
result = result[0]
|
||||
|
||||
|
||||
return Client(
|
||||
result[1],
|
||||
result[2],
|
||||
@@ -116,7 +122,9 @@ class ClientRepositoryService(ClientRepositoryABC):
|
||||
result[5],
|
||||
result[6],
|
||||
self._servers.get_server_by_id(result[7]),
|
||||
id=result[0],
|
||||
result[8],
|
||||
result[9],
|
||||
id=result[0]
|
||||
)
|
||||
|
||||
def find_client_by_discord_id_and_server_id(self, discord_id: int, server_id: int) -> Optional[Client]:
|
||||
@@ -127,9 +135,9 @@ class ClientRepositoryService(ClientRepositoryABC):
|
||||
result = self._context.select(Client.get_select_by_discord_id_and_server_id_string(discord_id, server_id))
|
||||
if result is None or len(result) == 0:
|
||||
return None
|
||||
|
||||
|
||||
result = result[0]
|
||||
|
||||
|
||||
return Client(
|
||||
result[1],
|
||||
result[2],
|
||||
@@ -138,7 +146,9 @@ class ClientRepositoryService(ClientRepositoryABC):
|
||||
result[5],
|
||||
result[6],
|
||||
self._servers.get_server_by_id(result[7]),
|
||||
id=result[0],
|
||||
result[8],
|
||||
result[9],
|
||||
id=result[0]
|
||||
)
|
||||
|
||||
def add_client(self, client: Client):
|
||||
@@ -156,14 +166,14 @@ class ClientRepositoryService(ClientRepositoryABC):
|
||||
def _get_client_and_server(self, id: int, server_id: int) -> Client:
|
||||
server = self._servers.find_server_by_discord_id(server_id)
|
||||
if server is None:
|
||||
self._logger.warn(__name__, f"Cannot find server by id {server_id}")
|
||||
raise Exception("Value not found")
|
||||
|
||||
self._logger.warn(__name__, f'Cannot find server by id {server_id}')
|
||||
raise Exception('Value not found')
|
||||
|
||||
client = self.find_client_by_discord_id_and_server_id(id, server.server_id)
|
||||
if client is None:
|
||||
self._logger.warn(__name__, f"Cannot find client by ids {id}@{server.server_id}")
|
||||
raise Exception("Value not found")
|
||||
|
||||
self._logger.warn(__name__, f'Cannot find client by ids {id}@{server.server_id}')
|
||||
raise Exception('Value not found')
|
||||
|
||||
return client
|
||||
|
||||
def append_sent_message_count(self, client_id: int, server_id: int, value: int):
|
||||
|
@@ -22,7 +22,12 @@ class ServerRepositoryService(ServerRepositoryABC):
|
||||
self._logger.trace(__name__, f"Send SQL command: {Server.get_select_all_string()}")
|
||||
results = self._context.select(Server.get_select_all_string())
|
||||
for result in results:
|
||||
servers.append(Server(result[1], id=result[0]))
|
||||
servers.append(Server(
|
||||
result[1],
|
||||
result[2],
|
||||
result[3],
|
||||
id=result[0]
|
||||
))
|
||||
|
||||
return servers
|
||||
|
||||
@@ -54,7 +59,12 @@ class ServerRepositoryService(ServerRepositoryABC):
|
||||
def get_server_by_id(self, server_id: int) -> Server:
|
||||
self._logger.trace(__name__, f"Send SQL command: {Server.get_select_by_id_string(server_id)}")
|
||||
result = self._context.select(Server.get_select_by_id_string(server_id))[0]
|
||||
return Server(result[1], id=result[0])
|
||||
return Server(
|
||||
result[1],
|
||||
result[2],
|
||||
result[3],
|
||||
id=result[0]
|
||||
)
|
||||
|
||||
def get_server_by_discord_id(self, discord_id: int) -> Server:
|
||||
self._logger.trace(
|
||||
@@ -62,7 +72,12 @@ class ServerRepositoryService(ServerRepositoryABC):
|
||||
f"Send SQL command: {Server.get_select_by_discord_id_string(discord_id)}",
|
||||
)
|
||||
result = self._context.select(Server.get_select_by_discord_id_string(discord_id))[0]
|
||||
return Server(result[1], id=result[0])
|
||||
return Server(
|
||||
result[1],
|
||||
result[2],
|
||||
result[3],
|
||||
id=result[0]
|
||||
)
|
||||
|
||||
def find_server_by_discord_id(self, discord_id: int) -> Optional[Server]:
|
||||
self._logger.trace(
|
||||
@@ -72,10 +87,15 @@ class ServerRepositoryService(ServerRepositoryABC):
|
||||
result = self._context.select(Server.get_select_by_discord_id_string(discord_id))
|
||||
if result is None or len(result) == 0:
|
||||
return None
|
||||
|
||||
|
||||
result = result[0]
|
||||
|
||||
return Server(result[1], result[2], result[3], id=result[0])
|
||||
return Server(
|
||||
result[1],
|
||||
result[2],
|
||||
result[3],
|
||||
id=result[0]
|
||||
)
|
||||
|
||||
def add_server(self, server: Server):
|
||||
self._logger.trace(__name__, f"Send SQL command: {server.insert_string}")
|
||||
|
Reference in New Issue
Block a user