diff --git a/src/gismo_data/abc/user_joined_server_repository_abc.py b/src/gismo_data/abc/user_joined_server_repository_abc.py index 49b8b7f..55de271 100644 --- a/src/gismo_data/abc/user_joined_server_repository_abc.py +++ b/src/gismo_data/abc/user_joined_server_repository_abc.py @@ -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 diff --git a/src/gismo_data/service/user_joined_server_repository_service.py b/src/gismo_data/service/user_joined_server_repository_service.py index 91fcbed..3cb5311 100644 --- a/src/gismo_data/service/user_joined_server_repository_service.py +++ b/src/gismo_data/service/user_joined_server_repository_service.py @@ -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] - )) - - return joins + 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] + ) - 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))