Added achievements to user profile #268_achievements
This commit is contained in:
parent
a71e3e4720
commit
aae6472e11
@ -76,7 +76,7 @@ class AchievementRepositoryService(AchievementRepositoryABC):
|
|||||||
achievements = List(Achievement)
|
achievements = List(Achievement)
|
||||||
achievements_joins = List(UserGotAchievement)
|
achievements_joins = List(UserGotAchievement)
|
||||||
self._logger.trace(__name__, f"Send SQL command: {UserGotAchievement.get_select_by_user_id_string(user_id)}")
|
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:
|
for result in results:
|
||||||
self._logger.trace(__name__, f"Got UserGotAchievement with id {result[0]}")
|
self._logger.trace(__name__, f"Got UserGotAchievement with id {result[0]}")
|
||||||
achievements_joins.append(self._join_from_result(result))
|
achievements_joins.append(self._join_from_result(result))
|
||||||
|
@ -17,6 +17,9 @@ type User implements TableWithHistoryQuery {
|
|||||||
userJoinedGameServerCount: Int
|
userJoinedGameServerCount: Int
|
||||||
userJoinedGameServers(filter: UserJoinedGameServerFilter, page: Page, sort: Sort): [UserJoinedGameServer]
|
userJoinedGameServers(filter: UserJoinedGameServerFilter, page: Page, sort: Sort): [UserJoinedGameServer]
|
||||||
|
|
||||||
|
achievementCount: Int
|
||||||
|
achievements(filter: AchievementFilter, page: Page, sort: Sort): [Achievement]
|
||||||
|
|
||||||
server: Server
|
server: Server
|
||||||
leftServer: Boolean
|
leftServer: Boolean
|
||||||
|
|
||||||
|
@ -2,12 +2,14 @@ from cpl_core.database.context import DatabaseContextABC
|
|||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
|
|
||||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
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_game_server_repository_abc import UserJoinedGameServerRepositoryABC
|
||||||
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
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.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC
|
||||||
from bot_data.model.user import User
|
from bot_data.model.user import User
|
||||||
from bot_data.model.user_history import UserHistory
|
from bot_data.model.user_history import UserHistory
|
||||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
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_game_server_filter import UserJoinedGameServerFilter
|
||||||
from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter
|
from bot_graphql.filter.user_joined_server_filter import UserJoinedServerFilter
|
||||||
from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter
|
from bot_graphql.filter.user_joined_voice_channel_filter import UserJoinedVoiceChannelFilter
|
||||||
@ -26,6 +28,7 @@ class UserQuery(DataQueryWithHistoryABC):
|
|||||||
ujvs: UserJoinedVoiceChannelRepositoryABC,
|
ujvs: UserJoinedVoiceChannelRepositoryABC,
|
||||||
user_joined_game_server: UserJoinedGameServerRepositoryABC,
|
user_joined_game_server: UserJoinedGameServerRepositoryABC,
|
||||||
permissions: PermissionServiceABC,
|
permissions: PermissionServiceABC,
|
||||||
|
achievements: AchievementRepositoryABC,
|
||||||
):
|
):
|
||||||
DataQueryWithHistoryABC.__init__(self, "User", "UsersHistory", UserHistory, db)
|
DataQueryWithHistoryABC.__init__(self, "User", "UsersHistory", UserHistory, db)
|
||||||
|
|
||||||
@ -36,6 +39,7 @@ class UserQuery(DataQueryWithHistoryABC):
|
|||||||
self._ujs = ujs
|
self._ujs = ujs
|
||||||
self._ujvs = ujvs
|
self._ujvs = ujvs
|
||||||
self._permissions = permissions
|
self._permissions = permissions
|
||||||
|
self._achievements = achievements
|
||||||
|
|
||||||
self.set_field("id", self.resolve_id)
|
self.set_field("id", self.resolve_id)
|
||||||
self.set_field("discordId", self.resolve_discord_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),
|
lambda user, *_: self._user_joined_game_server.get_user_joined_game_servers_by_user_id(user.id),
|
||||||
UserJoinedGameServerFilter,
|
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("server", self.resolve_server)
|
||||||
self.set_field("leftServer", self.resolve_left_server)
|
self.set_field("leftServer", self.resolve_left_server)
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ export interface Achievement extends DataWithHistory {
|
|||||||
operator?: string;
|
operator?: string;
|
||||||
value?: string;
|
value?: string;
|
||||||
server?: Server;
|
server?: Server;
|
||||||
|
|
||||||
|
createdAt?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AchievementFilter {
|
export interface AchievementFilter {
|
||||||
|
@ -4,6 +4,7 @@ import { Server, ServerFilter } from "./server.model";
|
|||||||
import { UserJoinedServer } from "./user_joined_server.model";
|
import { UserJoinedServer } from "./user_joined_server.model";
|
||||||
import { UserJoinedVoiceChannel } from "./user_joined_voice_channel.model";
|
import { UserJoinedVoiceChannel } from "./user_joined_voice_channel.model";
|
||||||
import { UserJoinedGameServer } from "./user_joined_game_server.model";
|
import { UserJoinedGameServer } from "./user_joined_game_server.model";
|
||||||
|
import { Achievement } from "./achievement.model";
|
||||||
|
|
||||||
export interface User extends DataWithHistory {
|
export interface User extends DataWithHistory {
|
||||||
id?: number;
|
id?: number;
|
||||||
@ -25,6 +26,9 @@ export interface User extends DataWithHistory {
|
|||||||
|
|
||||||
userJoinedGameServerCount?: number;
|
userJoinedGameServerCount?: number;
|
||||||
userJoinedGameServers?: UserJoinedGameServer[];
|
userJoinedGameServers?: UserJoinedGameServer[];
|
||||||
|
|
||||||
|
achievementCount?: number;
|
||||||
|
achievements?: Achievement[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserFilter {
|
export interface UserFilter {
|
||||||
|
@ -222,6 +222,12 @@ export class Queries {
|
|||||||
joinedOn
|
joinedOn
|
||||||
leavedOn
|
leavedOn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
achievements {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,27 @@
|
|||||||
|
|
||||||
<div class="content-divider"></div>
|
<div class="content-divider"></div>
|
||||||
|
|
||||||
|
<p-panel header="{{'view.server.profile.achievements.header' | translate}}" [toggleable]="true">
|
||||||
|
<div *ngFor="let achievement of user.achievements;">
|
||||||
|
<div class="content-row">
|
||||||
|
<div class="content-column">
|
||||||
|
<div class="content-data-name">{{'common.name' | translate}}:</div>
|
||||||
|
<div class="content-data-value">{{achievement.name}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content-column">
|
||||||
|
<div class="content-data-name">{{'common.name' | translate}}:</div>
|
||||||
|
<div class="content-data-value">{{achievement.name}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content-column">
|
||||||
|
<div class="content-data-name">{{'view.server.profile.achievements.time' | translate}}:</div>
|
||||||
|
<div class="content-data-value">{{achievement.createdAt | date:'dd.MM.yyyy HH:mm:ss'}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</p-panel>
|
||||||
|
|
||||||
<p-panel header="{{'view.server.profile.joined_voice_channel.header' | translate}}" [toggleable]="true">
|
<p-panel header="{{'view.server.profile.joined_voice_channel.header' | translate}}" [toggleable]="true">
|
||||||
<div *ngFor="let join of user.joinedVoiceChannels;">
|
<div *ngFor="let join of user.joinedVoiceChannels;">
|
||||||
<div class="content-row">
|
<div class="content-row">
|
||||||
@ -102,8 +123,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</p-panel>
|
</p-panel>
|
||||||
|
|
||||||
<p-panel header="{{'view.server.profile.joined_game_server.header' | translate}}" [toggleable]="true">
|
<p-panel header="{{'view.server.profile.joined_game_server.header' | translate}}" [toggleable]="true">
|
||||||
<div *ngFor="let join of user.userJoinedGameServers;">
|
<div *ngFor="let join of user.userJoinedGameServers;">
|
||||||
<div class="content-row">
|
<div class="content-row">
|
||||||
|
@ -97,6 +97,7 @@
|
|||||||
"wrong_password": "Falsches Passwort"
|
"wrong_password": "Falsches Passwort"
|
||||||
},
|
},
|
||||||
"register": {
|
"register": {
|
||||||
|
"confirm_privacy": "Ich erkläre mich mit der <a href=\"{{url}}\">Datenschutzerklärung</a> einverstanden.",
|
||||||
"email_required": "E-Mail benötigt",
|
"email_required": "E-Mail benötigt",
|
||||||
"emails_not_match": "E-Mails stimmen nicht überein",
|
"emails_not_match": "E-Mails stimmen nicht überein",
|
||||||
"first_name": "Vorname",
|
"first_name": "Vorname",
|
||||||
@ -113,8 +114,7 @@
|
|||||||
"register_with_discord": "Mit Discord Registrieren",
|
"register_with_discord": "Mit Discord Registrieren",
|
||||||
"repeat_email": "E-Mail wiederholen",
|
"repeat_email": "E-Mail wiederholen",
|
||||||
"repeat_password": "Passwort wiederholen",
|
"repeat_password": "Passwort wiederholen",
|
||||||
"user_already_exists": "Benutzer existiert bereits",
|
"user_already_exists": "Benutzer existiert bereits"
|
||||||
"confirm_privacy": "Ich erkläre mich mit der <a href=\"{{url}}\">Datenschutzerklärung</a> einverstanden."
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
@ -153,6 +153,7 @@
|
|||||||
"joined_at": "Beigetreten am",
|
"joined_at": "Beigetreten am",
|
||||||
"leaved_at": "Verlassen am",
|
"leaved_at": "Verlassen am",
|
||||||
"modified_at": "Bearbeitet am",
|
"modified_at": "Bearbeitet am",
|
||||||
|
"name": "Name",
|
||||||
"no_entries_found": "Keine Einträge gefunden",
|
"no_entries_found": "Keine Einträge gefunden",
|
||||||
"of": "von",
|
"of": "von",
|
||||||
"reset_filters": "Filter zurücksetzen"
|
"reset_filters": "Filter zurücksetzen"
|
||||||
@ -276,12 +277,12 @@
|
|||||||
"dashboard": "Dashboard",
|
"dashboard": "Dashboard",
|
||||||
"members": "Mitglieder",
|
"members": "Mitglieder",
|
||||||
"server": {
|
"server": {
|
||||||
|
"achievements": "Errungenschaften",
|
||||||
"auto_roles": "Auto Rollen",
|
"auto_roles": "Auto Rollen",
|
||||||
"dashboard": "Dashboard",
|
"dashboard": "Dashboard",
|
||||||
"levels": "Level",
|
"levels": "Level",
|
||||||
"members": "Mitglieder",
|
"members": "Mitglieder",
|
||||||
"profile": "Dein Profil",
|
"profile": "Dein Profil"
|
||||||
"achievements": "Errungenschaften"
|
|
||||||
},
|
},
|
||||||
"server_empty": "Kein Server ausgewählt",
|
"server_empty": "Kein Server ausgewählt",
|
||||||
"settings": "Einstellungen",
|
"settings": "Einstellungen",
|
||||||
@ -316,6 +317,32 @@
|
|||||||
"servers": "Server"
|
"servers": "Server"
|
||||||
},
|
},
|
||||||
"server": {
|
"server": {
|
||||||
|
"achievements": {
|
||||||
|
"achievements": "Errungenschaften",
|
||||||
|
"header": "Errungenschaften",
|
||||||
|
"headers": {
|
||||||
|
"attribute": "Attribut",
|
||||||
|
"name": "Name",
|
||||||
|
"operator": "Operator",
|
||||||
|
"value": "Wert"
|
||||||
|
},
|
||||||
|
"message": {
|
||||||
|
"achievement_create": "Errungenschaft erstellt",
|
||||||
|
"achievement_create_d": "Errungenschaft {{name}} erfolgreich erstellt",
|
||||||
|
"achievement_create_failed": "Errungenschaft Erstellung fehlgeschlagen",
|
||||||
|
"achievement_create_failed_d": "Die Erstellung der Errungenschaft ist fehlgeschlagen!",
|
||||||
|
"achievement_delete": "Errungenschaft löschen",
|
||||||
|
"achievement_delete_failed": "Errungenschaft Löschung fehlgeschlagen",
|
||||||
|
"achievement_delete_failed_d": "Die Löschung der Errungenschaft {{name}} ist fehlgeschlagen!",
|
||||||
|
"achievement_delete_q": "Sind Sie sich sicher, dass Sie das Errungenschaft {{name}} löschen möchten?",
|
||||||
|
"achievement_deleted": "Errungenschaft gelöscht",
|
||||||
|
"achievement_deleted_d": "Errungenschaft {{name}} erfolgreich gelöscht",
|
||||||
|
"achievement_update": "Errungenschaft bearbeitet",
|
||||||
|
"achievement_update_d": "Errungenschaft {{name}} erfolgreich bearbeitet",
|
||||||
|
"achievement_update_failed": "Errungenschaft Bearbeitung fehlgeschlagen",
|
||||||
|
"achievement_update_failed_d": "Die Bearbeitung der Errungenschaft ist fehlgeschlagen!"
|
||||||
|
}
|
||||||
|
},
|
||||||
"auto_roles": {
|
"auto_roles": {
|
||||||
"auto_roles": "Auto Rollen",
|
"auto_roles": "Auto Rollen",
|
||||||
"header": "Auto Rollen",
|
"header": "Auto Rollen",
|
||||||
@ -398,32 +425,6 @@
|
|||||||
"level_update_failed_d": "Die Bearbeitung des Levels ist fehlgeschlagen!"
|
"level_update_failed_d": "Die Bearbeitung des Levels ist fehlgeschlagen!"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"achievements": {
|
|
||||||
"header": "Errungenschaften",
|
|
||||||
"headers": {
|
|
||||||
"name": "Name",
|
|
||||||
"attribute": "Attribut",
|
|
||||||
"operator": "Operator",
|
|
||||||
"value": "Wert"
|
|
||||||
},
|
|
||||||
"achievements": "Errungenschaften",
|
|
||||||
"message": {
|
|
||||||
"achievement_create": "Errungenschaft erstellt",
|
|
||||||
"achievement_create_d": "Errungenschaft {{name}} erfolgreich erstellt",
|
|
||||||
"achievement_create_failed": "Errungenschaft Erstellung fehlgeschlagen",
|
|
||||||
"achievement_create_failed_d": "Die Erstellung der Errungenschaft ist fehlgeschlagen!",
|
|
||||||
"achievement_delete": "Errungenschaft löschen",
|
|
||||||
"achievement_delete_failed": "Errungenschaft Löschung fehlgeschlagen",
|
|
||||||
"achievement_delete_failed_d": "Die Löschung der Errungenschaft {{name}} ist fehlgeschlagen!",
|
|
||||||
"achievement_delete_q": "Sind Sie sich sicher, dass Sie das Errungenschaft {{name}} löschen möchten?",
|
|
||||||
"achievement_deleted": "Errungenschaft gelöscht",
|
|
||||||
"achievement_deleted_d": "Errungenschaft {{name}} erfolgreich gelöscht",
|
|
||||||
"achievement_update": "Errungenschaft bearbeitet",
|
|
||||||
"achievement_update_d": "Errungenschaft {{name}} erfolgreich bearbeitet",
|
|
||||||
"achievement_update_failed": "Errungenschaft Bearbeitung fehlgeschlagen",
|
|
||||||
"achievement_update_failed_d": "Die Bearbeitung der Errungenschaft ist fehlgeschlagen!"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"members": {
|
"members": {
|
||||||
"header": "Mitglieder",
|
"header": "Mitglieder",
|
||||||
"headers": {
|
"headers": {
|
||||||
@ -442,6 +443,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
|
"achievements": {
|
||||||
|
"header": "Errungeschaften",
|
||||||
|
"time": "Erreicht am"
|
||||||
|
},
|
||||||
"header": "Dein Profil",
|
"header": "Dein Profil",
|
||||||
"joined_game_server": {
|
"joined_game_server": {
|
||||||
"header": "Gameserver-beitritte",
|
"header": "Gameserver-beitritte",
|
||||||
|
@ -97,6 +97,7 @@
|
|||||||
"wrong_password": "Wrong password"
|
"wrong_password": "Wrong password"
|
||||||
},
|
},
|
||||||
"register": {
|
"register": {
|
||||||
|
"confirm_privacy": "I agree to the <a href=\"{{url}}\">Privacy Policy</a>.",
|
||||||
"email_required": "E-Mail required",
|
"email_required": "E-Mail required",
|
||||||
"emails_not_match": "E-Mails do not match",
|
"emails_not_match": "E-Mails do not match",
|
||||||
"first_name": "First name",
|
"first_name": "First name",
|
||||||
@ -113,8 +114,7 @@
|
|||||||
"register_with_discord": "Register with discord",
|
"register_with_discord": "Register with discord",
|
||||||
"repeat_email": "Repeat E-mail",
|
"repeat_email": "Repeat E-mail",
|
||||||
"repeat_password": "Repeat password",
|
"repeat_password": "Repeat password",
|
||||||
"user_already_exists": "User already exists",
|
"user_already_exists": "User already exists"
|
||||||
"confirm_privacy": "I agree to the <a href=\"{{url}}\">Privacy Policy</a>."
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
@ -153,6 +153,7 @@
|
|||||||
"joined_at": "Joined at",
|
"joined_at": "Joined at",
|
||||||
"leaved_at": "Leaved at",
|
"leaved_at": "Leaved at",
|
||||||
"modified_at": "Modified at",
|
"modified_at": "Modified at",
|
||||||
|
"name": "Name",
|
||||||
"no_entries_found": "No entries found",
|
"no_entries_found": "No entries found",
|
||||||
"of": "of",
|
"of": "of",
|
||||||
"reset_filters": "Reset filters"
|
"reset_filters": "Reset filters"
|
||||||
@ -276,6 +277,7 @@
|
|||||||
"dashboard": "Dashboard",
|
"dashboard": "Dashboard",
|
||||||
"members": "Members",
|
"members": "Members",
|
||||||
"server": {
|
"server": {
|
||||||
|
"achievements": "Achievements",
|
||||||
"auto_roles": "Auto role",
|
"auto_roles": "Auto role",
|
||||||
"dashboard": "Dashboard",
|
"dashboard": "Dashboard",
|
||||||
"levels": "Level",
|
"levels": "Level",
|
||||||
@ -315,6 +317,32 @@
|
|||||||
"servers": "Server"
|
"servers": "Server"
|
||||||
},
|
},
|
||||||
"server": {
|
"server": {
|
||||||
|
"achievements": {
|
||||||
|
"achievements": "Achievements",
|
||||||
|
"header": "Achievements",
|
||||||
|
"headers": {
|
||||||
|
"attribute": "Attribute",
|
||||||
|
"name": "Namer",
|
||||||
|
"operator": "Operator",
|
||||||
|
"value": "Value"
|
||||||
|
},
|
||||||
|
"message": {
|
||||||
|
"achievement_create": "Achievement created",
|
||||||
|
"achievement_create_d": "Achievement {{name}} successfully created",
|
||||||
|
"achievement_create_failed": "Achievement creation failed",
|
||||||
|
"achievement_create_failed_d": "Creation of achievement failed!",
|
||||||
|
"achievement_delete": "Delete achievement",
|
||||||
|
"achievement_delete_failed": "Achievement deletion failed",
|
||||||
|
"achievement_delete_failed_d": "Deletion of achievement {{name}} failed!",
|
||||||
|
"achievement_delete_q": "Are you sure you want to delete the {{name}} achievement?",
|
||||||
|
"achievement_deleted": "Achievement deleted",
|
||||||
|
"achievement_deleted_d": "Achievement {{name}} successfully deleted\t",
|
||||||
|
"achievement_update": "Achievement edited",
|
||||||
|
"achievement_update_d": "Achievement {{name}} edited successfully",
|
||||||
|
"achievement_update_failed": "Achievement editing failed",
|
||||||
|
"achievement_update_failed_d": "Achievement editing failed!"
|
||||||
|
}
|
||||||
|
},
|
||||||
"auto_roles": {
|
"auto_roles": {
|
||||||
"auto_roles": "Auto roles",
|
"auto_roles": "Auto roles",
|
||||||
"header": "Auto roles",
|
"header": "Auto roles",
|
||||||
@ -415,6 +443,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
|
"achievements": {
|
||||||
|
"header": "Achievements",
|
||||||
|
"time": "Reached at"
|
||||||
|
},
|
||||||
"header": "Profile",
|
"header": "Profile",
|
||||||
"joined_game_server": {
|
"joined_game_server": {
|
||||||
"header": "Game server accessions",
|
"header": "Game server accessions",
|
||||||
|
Loading…
Reference in New Issue
Block a user