Added achievements to user profile #268_achievements
This commit is contained in:
@@ -76,7 +76,7 @@ class AchievementRepositoryService(AchievementRepositoryABC):
|
||||
achievements = List(Achievement)
|
||||
achievements_joins = List(UserGotAchievement)
|
||||
self._logger.trace(__name__, f"Send SQL command: {UserGotAchievement.get_select_by_user_id_string(user_id)}")
|
||||
results = self._context.select(UserGotAchievement.get_select_all_string())
|
||||
results = self._context.select(UserGotAchievement.get_select_by_user_id_string(user_id))
|
||||
for result in results:
|
||||
self._logger.trace(__name__, f"Got UserGotAchievement with id {result[0]}")
|
||||
achievements_joins.append(self._join_from_result(result))
|
||||
|
@@ -17,6 +17,9 @@ type User implements TableWithHistoryQuery {
|
||||
userJoinedGameServerCount: Int
|
||||
userJoinedGameServers(filter: UserJoinedGameServerFilter, page: Page, sort: Sort): [UserJoinedGameServer]
|
||||
|
||||
achievementCount: Int
|
||||
achievements(filter: AchievementFilter, page: Page, sort: Sort): [Achievement]
|
||||
|
||||
server: Server
|
||||
leftServer: Boolean
|
||||
|
||||
|
@@ -2,12 +2,14 @@ from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
from bot_data.abc.achievement_repository_abc import AchievementRepositoryABC
|
||||
from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC
|
||||
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
||||
from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC
|
||||
from bot_data.model.user import User
|
||||
from bot_data.model.user_history import UserHistory
|
||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
||||
from bot_graphql.filter.achievement_filter import AchievementFilter
|
||||
from bot_graphql.filter.user_joined_game_server_filter import UserJoinedGameServerFilter
|
||||
from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter
|
||||
from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter
|
||||
@@ -26,6 +28,7 @@ class UserQuery(DataQueryWithHistoryABC):
|
||||
ujvs: UserJoinedVoiceChannelRepositoryABC,
|
||||
user_joined_game_server: UserJoinedGameServerRepositoryABC,
|
||||
permissions: PermissionServiceABC,
|
||||
achievements: AchievementRepositoryABC,
|
||||
):
|
||||
DataQueryWithHistoryABC.__init__(self, "User", "UsersHistory", UserHistory, db)
|
||||
|
||||
@@ -36,6 +39,7 @@ class UserQuery(DataQueryWithHistoryABC):
|
||||
self._ujs = ujs
|
||||
self._ujvs = ujvs
|
||||
self._permissions = permissions
|
||||
self._achievements = achievements
|
||||
|
||||
self.set_field("id", self.resolve_id)
|
||||
self.set_field("discordId", self.resolve_discord_id)
|
||||
@@ -60,6 +64,10 @@ class UserQuery(DataQueryWithHistoryABC):
|
||||
lambda user, *_: self._user_joined_game_server.get_user_joined_game_servers_by_user_id(user.id),
|
||||
UserJoinedGameServerFilter,
|
||||
)
|
||||
self.add_collection(
|
||||
"achievement", lambda user, *_: achievements.get_achievements_by_user_id(user.id), AchievementFilter
|
||||
)
|
||||
|
||||
self.set_field("server", self.resolve_server)
|
||||
self.set_field("leftServer", self.resolve_left_server)
|
||||
|
||||
|
Reference in New Issue
Block a user