From cab65477b099c853b57da4b958170a2b058ddf9d Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 12 Jul 2023 22:34:00 +0200 Subject: [PATCH] Improved achievement endpoint #268_achievements --- kdb-bot/src/bot_data/model/achievement.py | 4 ++++ kdb-bot/src/bot_graphql/model/user.gql | 2 ++ kdb-bot/src/bot_graphql/queries/user_query.py | 2 ++ 3 files changed, 8 insertions(+) diff --git a/kdb-bot/src/bot_data/model/achievement.py b/kdb-bot/src/bot_data/model/achievement.py index e01bafad..be78379e 100644 --- a/kdb-bot/src/bot_data/model/achievement.py +++ b/kdb-bot/src/bot_data/model/achievement.py @@ -21,6 +21,10 @@ class Achievement(TableABC): self._id = id self._name = name self._attribute = attribute + + if operator not in ["==", "!=", "<=", ">=", "<", ">"]: + raise ValueError("operator must be ==,!=,<=,>=,< or >") + self._operator = operator self._value = value self._server = server diff --git a/kdb-bot/src/bot_graphql/model/user.gql b/kdb-bot/src/bot_graphql/model/user.gql index e7f03f38..2925e223 100644 --- a/kdb-bot/src/bot_graphql/model/user.gql +++ b/kdb-bot/src/bot_graphql/model/user.gql @@ -3,6 +3,8 @@ type User implements TableWithHistoryQuery { discordId: String name: String xp: Int + messageCount: Int + reactionCount: Int ontime: Float level: Level diff --git a/kdb-bot/src/bot_graphql/queries/user_query.py b/kdb-bot/src/bot_graphql/queries/user_query.py index 9e924f5f..53c6a7c1 100644 --- a/kdb-bot/src/bot_graphql/queries/user_query.py +++ b/kdb-bot/src/bot_graphql/queries/user_query.py @@ -41,6 +41,8 @@ class UserQuery(DataQueryWithHistoryABC): self.set_field("discordId", self.resolve_discord_id) self.set_field("name", self.resolve_name) 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("ontime", self.resolve_ontime) self.set_field("level", self.resolve_level) self.add_collection(