Fixed user_joined_server repo

This commit is contained in:
Sven Heidemann 2021-12-08 18:42:52 +01:00
parent 789186454e
commit 7e6485459b
2 changed files with 12 additions and 16 deletions

View File

@ -17,7 +17,7 @@ class UserJoinedServerRepositoryABC(ABC):
def get_user_joined_server_by_id(self, id: int) -> UserJoinedServer: pass
@abstractmethod
def get_user_joined_server_by_user_id(self, user_id: int) -> UserJoinedServer: pass
def get_user_joined_servers_by_user_id(self, user_id: int) -> list[UserJoinedServer]: pass
@abstractmethod
def get_active_user_joined_server_by_user_id(self, user_id: int) -> UserJoinedServer: pass

View File

@ -37,23 +37,19 @@ class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC):
return joins
def get_user_joined_server_by_id(self, id: int) -> List[UserJoinedServer]:
joins = List(UserJoinedServer)
def get_user_joined_server_by_id(self, id: int) -> UserJoinedServer:
self._logger.trace(__name__, f'Send SQL command: {UserJoinedServer.get_select_by_id_string(id)}')
results = self._context.select(UserJoinedServer.get_select_by_id_string(id))
for result in results:
joins.append(UserJoinedServer(
self._users.get_user_by_id(result[1]),
result[2],
result[3],
result[4],
result[5],
id=result[0]
))
result = self._context.select(UserJoinedServer.get_select_by_id_string(id))[0]
return UserJoinedServer(
self._users.get_user_by_id(result[1]),
result[2],
result[3],
result[4],
result[5],
id=result[0]
)
return joins
def get_user_joined_server_by_user_id(self, user_id: int) -> List[UserJoinedServer]:
def get_user_joined_servers_by_user_id(self, user_id: int) -> List[UserJoinedServer]:
joins = List(UserJoinedServer)
self._logger.trace(__name__, f'Send SQL command: {UserJoinedServer.get_select_by_user_id_string(user_id)}')
results = self._context.select(UserJoinedServer.get_select_by_user_id_string(user_id))