From 804aa0b9b853ef96aaddee3006aa4eacaedd49b8 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 7 Nov 2023 18:15:41 +0100 Subject: [PATCH] Fixed some histories --- bot/src/bot_data/model/user.py | 4 ++-- bot/src/bot_data/model/user_history.py | 9 +++++++++ bot/src/bot_graphql/graphql/user.gql | 3 +++ bot/src/bot_graphql/queries/user_history_query.py | 3 +++ web/src/app/models/graphql/queries.model.ts | 1 - 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bot/src/bot_data/model/user.py b/bot/src/bot_data/model/user.py index c5766eb6..5d8ac8c2 100644 --- a/bot/src/bot_data/model/user.py +++ b/bot/src/bot_data/model/user.py @@ -82,11 +82,11 @@ class User(TableABC): self._reaction_count = value @property - def birthday(self) -> Optional[datetime]: + def birthday(self) -> Optional[date]: return self._birthday @birthday.setter - def birthday(self, value: Optional[datetime]): + def birthday(self, value: Optional[date]): self._birthday = value @property diff --git a/bot/src/bot_data/model/user_history.py b/bot/src/bot_data/model/user_history.py index 357c854a..eebd1d8f 100644 --- a/bot/src/bot_data/model/user_history.py +++ b/bot/src/bot_data/model/user_history.py @@ -1,3 +1,6 @@ +from datetime import date +from typing import Optional + from cpl_core.dependency_injection import ServiceProviderABC from cpl_query.extension import List @@ -11,6 +14,7 @@ class UserHistory(HistoryTableABC): xp: int, message_count: int, reaction_count: int, + birthday: Optional[date], server: int, deleted: bool, date_from: str, @@ -24,6 +28,7 @@ class UserHistory(HistoryTableABC): self._xp = xp self._message_count = message_count self._reaction_count = reaction_count + self._birthday = birthday self._server = server self._deleted = deleted @@ -50,6 +55,10 @@ class UserHistory(HistoryTableABC): def reaction_count(self) -> int: return self._reaction_count + @property + def birthday(self) -> Optional[date]: + return self._birthday + @property def server(self) -> int: return self._server diff --git a/bot/src/bot_graphql/graphql/user.gql b/bot/src/bot_graphql/graphql/user.gql index 9ffff9a2..f05ee950 100644 --- a/bot/src/bot_graphql/graphql/user.gql +++ b/bot/src/bot_graphql/graphql/user.gql @@ -37,6 +37,9 @@ type UserHistory implements HistoryTableQuery { id: ID discordId: String xp: Int + messageCount: Int + reactionCount: Int + birthday: String server: ID diff --git a/bot/src/bot_graphql/queries/user_history_query.py b/bot/src/bot_graphql/queries/user_history_query.py index 14d3867b..75970bff 100644 --- a/bot/src/bot_graphql/queries/user_history_query.py +++ b/bot/src/bot_graphql/queries/user_history_query.py @@ -9,6 +9,9 @@ class UserHistoryQuery(HistoryQueryABC): self.set_field("id", self.resolve_id) self.set_field("discordId", self.resolve_discord_id) self.set_field("xp", self.resolve_xp) + self.set_field("messageCount", lambda x, *_: x.message_count) + self.set_field("reactionCount", lambda x, *_: x.reaction_count) + self.set_field("birthday", lambda x, *_: None if x.birthday is None else x.birthday.strftime("%d.%m.%Y")) self.set_field("server", self.resolve_server) @staticmethod diff --git a/web/src/app/models/graphql/queries.model.ts b/web/src/app/models/graphql/queries.model.ts index 09e582d5..e44e3aab 100644 --- a/web/src/app/models/graphql/queries.model.ts +++ b/web/src/app/models/graphql/queries.model.ts @@ -268,7 +268,6 @@ export class Queries { id shortName roleId - roleName position server deleted