From 5d470be58395fe55b14954039c836856d5eda8a9 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 8 Feb 2023 19:05:32 +0100 Subject: [PATCH] Changed from snake to camel case #162 --- .../abc/user_joined_server_repository_abc.py | 5 +++ .../src/bot_data/model/user_joined_server.py | 11 ++++-- .../user_joined_server_repository_service.py | 15 ++++++++ kdb-bot/src/bot_graphql/abc/query_abc.py | 2 +- .../bot_graphql/filter/auto_role_filter.py | 12 +++---- .../filter/auto_role_rule_filter.py | 14 ++++---- .../src/bot_graphql/filter/client_filter.py | 4 +-- kdb-bot/src/bot_graphql/filter/page.py | 8 ++--- .../src/bot_graphql/filter/server_filter.py | 4 +-- kdb-bot/src/bot_graphql/filter/sort.py | 8 ++--- kdb-bot/src/bot_graphql/filter/user_filter.py | 4 +-- .../filter/user_joined_server_filter.py | 8 ++--- .../user_joined_voice_channel_filter.py | 16 ++++----- kdb-bot/src/bot_graphql/graphql_module.py | 4 +++ kdb-bot/src/bot_graphql/model/autoRole.gql | 35 +++++++++++++++++++ .../src/bot_graphql/model/autoRoleRule.gql | 32 +++++++++++++++++ kdb-bot/src/bot_graphql/model/auto_role.gql | 35 ------------------- .../src/bot_graphql/model/auto_role_rule.gql | 32 ----------------- kdb-bot/src/bot_graphql/model/base.gql | 12 +++---- kdb-bot/src/bot_graphql/model/client.gql | 18 +++++----- kdb-bot/src/bot_graphql/model/knownUser.gql | 7 ++++ kdb-bot/src/bot_graphql/model/known_user.gql | 7 ---- kdb-bot/src/bot_graphql/model/level.gql | 16 ++++----- kdb-bot/src/bot_graphql/model/mutation.gql | 4 +-- kdb-bot/src/bot_graphql/model/query.gql | 28 +++++++-------- kdb-bot/src/bot_graphql/model/server.gql | 22 ++++++------ kdb-bot/src/bot_graphql/model/user.gql | 18 +++++----- ...joined_server.gql => userJoinedServer.gql} | 12 +++---- .../model/userJoinedVoiceChannel.gql | 20 +++++++++++ .../model/user_joined_voice_channel.gql | 20 ----------- kdb-bot/src/bot_graphql/mutation.py | 27 +++++++++++++- .../mutations/auto_role_mutation.py | 20 +++++------ .../mutations/auto_role_rule_mutation.py | 18 +++++----- .../bot_graphql/mutations/level_mutation.py | 12 +++---- .../bot_graphql/mutations/user_mutation.py | 2 +- .../bot_graphql/queries/auto_role_query.py | 8 ++--- .../queries/auto_role_rule_query.py | 8 ++--- .../src/bot_graphql/queries/client_query.py | 12 +++---- .../bot_graphql/queries/known_user_query.py | 2 +- .../src/bot_graphql/queries/level_query.py | 2 +- .../src/bot_graphql/queries/server_query.py | 15 +++++--- .../queries/user_joined_server_query.py | 4 +-- .../user_joined_voice_channel_query.py | 8 ++--- kdb-bot/src/bot_graphql/queries/user_query.py | 8 ++--- kdb-bot/src/bot_graphql/query.py | 10 +++--- 45 files changed, 323 insertions(+), 266 deletions(-) create mode 100644 kdb-bot/src/bot_graphql/model/autoRole.gql create mode 100644 kdb-bot/src/bot_graphql/model/autoRoleRule.gql delete mode 100644 kdb-bot/src/bot_graphql/model/auto_role.gql delete mode 100644 kdb-bot/src/bot_graphql/model/auto_role_rule.gql create mode 100644 kdb-bot/src/bot_graphql/model/knownUser.gql delete mode 100644 kdb-bot/src/bot_graphql/model/known_user.gql rename kdb-bot/src/bot_graphql/model/{user_joined_server.gql => userJoinedServer.gql} (51%) create mode 100644 kdb-bot/src/bot_graphql/model/userJoinedVoiceChannel.gql delete mode 100644 kdb-bot/src/bot_graphql/model/user_joined_voice_channel.gql diff --git a/kdb-bot/src/bot_data/abc/user_joined_server_repository_abc.py b/kdb-bot/src/bot_data/abc/user_joined_server_repository_abc.py index 2b8dcc5f..cbc3a718 100644 --- a/kdb-bot/src/bot_data/abc/user_joined_server_repository_abc.py +++ b/kdb-bot/src/bot_data/abc/user_joined_server_repository_abc.py @@ -2,6 +2,7 @@ from abc import ABC, abstractmethod from typing import Optional from cpl_query.extension import List + from bot_data.model.user_joined_server import UserJoinedServer @@ -18,6 +19,10 @@ class UserJoinedServerRepositoryABC(ABC): def get_user_joined_server_by_id(self, id: int) -> UserJoinedServer: pass + @abstractmethod + def get_user_joined_server_by_server_id(self, server_id: int) -> UserJoinedServer: + pass + @abstractmethod def get_user_joined_servers_by_user_id(self, user_id: int) -> list[UserJoinedServer]: pass diff --git a/kdb-bot/src/bot_data/model/user_joined_server.py b/kdb-bot/src/bot_data/model/user_joined_server.py index 7c0764d1..134e2f47 100644 --- a/kdb-bot/src/bot_data/model/user_joined_server.py +++ b/kdb-bot/src/bot_data/model/user_joined_server.py @@ -1,10 +1,8 @@ from datetime import datetime -from typing import Optional from cpl_core.database import TableABC from bot_data.model.user import User -from bot_data.model.server import Server class UserJoinedServer(TableABC): @@ -69,6 +67,15 @@ class UserJoinedServer(TableABC): """ ) + @staticmethod + def get_select_by_server_id_string(id: int) -> str: + return str( + f""" + SELECT * FROM `UserJoinedServers` + WHERE `ServerId` = {id}; + """ + ) + @staticmethod def get_select_by_user_id_string(id: int) -> str: return str( diff --git a/kdb-bot/src/bot_data/service/user_joined_server_repository_service.py b/kdb-bot/src/bot_data/service/user_joined_server_repository_service.py index 3c8a9d4b..abd0a17b 100644 --- a/kdb-bot/src/bot_data/service/user_joined_server_repository_service.py +++ b/kdb-bot/src/bot_data/service/user_joined_server_repository_service.py @@ -57,6 +57,21 @@ class UserJoinedServerRepositoryService(UserJoinedServerRepositoryABC): id=result[0], ) + def get_user_joined_server_by_server_id(self, server_id: int) -> UserJoinedServer: + self._logger.trace( + __name__, + f"Send SQL command: {UserJoinedServer.get(id)}", + ) + 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_servers_by_user_id(self, user_id: int) -> List[UserJoinedServer]: joins = List(UserJoinedServer) self._logger.trace( diff --git a/kdb-bot/src/bot_graphql/abc/query_abc.py b/kdb-bot/src/bot_graphql/abc/query_abc.py index e52e927a..4e291ae4 100644 --- a/kdb-bot/src/bot_graphql/abc/query_abc.py +++ b/kdb-bot/src/bot_graphql/abc/query_abc.py @@ -34,7 +34,7 @@ class QueryABC(ObjectType): return self._resolve_collection(get_collection(*args), *args, **kwargs) self.set_field(f"{name}s", wrapper) - self.set_field(f"{name}_count", lambda *args: get_collection(*args).count()) + self.set_field(f"{name}Count", lambda *args: get_collection(*args).count()) # @FilterABC.resolve_filter_annotation def _resolve_collection(self, collection: List, *_, filter: FilterABC = None, page: Page = None, sort: Sort = None): diff --git a/kdb-bot/src/bot_graphql/filter/auto_role_filter.py b/kdb-bot/src/bot_graphql/filter/auto_role_filter.py index 8badeea9..ca02a7d4 100644 --- a/kdb-bot/src/bot_graphql/filter/auto_role_filter.py +++ b/kdb-bot/src/bot_graphql/filter/auto_role_filter.py @@ -24,14 +24,14 @@ class AutoRoleFilter(FilterABC): if "id" in values: self._id = int(values["id"]) - if "channel_id" in values: - self._channel_id = int(values["channel_id"]) + if "channelId" in values: + self._channel_id = int(values["channelId"]) - if "channel_name" in values: - self._channel_name = values["channel_name"] + if "channelName" in values: + self._channel_name = values["channelName"] - if "message_id" in values: - self._message_id = int(values["message_id"]) + if "messageId" in values: + self._message_id = int(values["messageId"]) if "server" in values: from bot_graphql.filter.server_filter import ServerFilter diff --git a/kdb-bot/src/bot_graphql/filter/auto_role_rule_filter.py b/kdb-bot/src/bot_graphql/filter/auto_role_rule_filter.py index ebc89242..44651957 100644 --- a/kdb-bot/src/bot_graphql/filter/auto_role_rule_filter.py +++ b/kdb-bot/src/bot_graphql/filter/auto_role_rule_filter.py @@ -22,16 +22,16 @@ class AutoRoleRuleFilter(FilterABC): if "id" in values: self._id = int(values["id"]) - if "emoji_name" in values: - self._emoji_name = values["emoji_name"] + if "emojiName" in values: + self._emoji_name = values["emojiName"] - if "role_id" in values: - self._role_id = int(values["role_id"]) + if "roleId" in values: + self._role_id = int(values["roleId"]) - if "role_name" in values: - self._role_name = values["role_name"] + if "roleName" in values: + self._role_name = values["roleName"] - if "auto_role" in values: + if "autoRole" in values: from bot_graphql.filter.auto_role_filter import AutoRoleFilter self._auto_role: AutoRoleFilter = self._services.get_service(AutoRoleFilter) diff --git a/kdb-bot/src/bot_graphql/filter/client_filter.py b/kdb-bot/src/bot_graphql/filter/client_filter.py index 2d1fd20a..be81e742 100644 --- a/kdb-bot/src/bot_graphql/filter/client_filter.py +++ b/kdb-bot/src/bot_graphql/filter/client_filter.py @@ -17,8 +17,8 @@ class ClientFilter(FilterABC): if "id" in values: self._id = int(values["id"]) - if "discord_id" in values: - self._id = int(values["discord_id"]) + if "discordId" in values: + self._id = int(values["discordId"]) if "name" in values: self._name = values["name"] diff --git a/kdb-bot/src/bot_graphql/filter/page.py b/kdb-bot/src/bot_graphql/filter/page.py index 60978d31..b54080c9 100644 --- a/kdb-bot/src/bot_graphql/filter/page.py +++ b/kdb-bot/src/bot_graphql/filter/page.py @@ -10,11 +10,11 @@ class Page(FilterABC): self._page_size = None def from_dict(self, values: dict): - if "page_index" in values: - self._page_index = int(values["page_index"]) + if "pageIndex" in values: + self._page_index = int(values["pageIndex"]) - if "page_size" in values: - self._page_size = int(values["page_size"]) + if "pageSize" in values: + self._page_size = int(values["pageSize"]) def filter(self, query: List, *args) -> List: if self._page_size is not None and self._page_index is not None: diff --git a/kdb-bot/src/bot_graphql/filter/server_filter.py b/kdb-bot/src/bot_graphql/filter/server_filter.py index 2ae039a0..2964d1d7 100644 --- a/kdb-bot/src/bot_graphql/filter/server_filter.py +++ b/kdb-bot/src/bot_graphql/filter/server_filter.py @@ -19,8 +19,8 @@ class ServerFilter(FilterABC): if "id" in values: self._id = int(values["id"]) - if "discord_id" in values: - self._discord_id = int(values["discord_id"]) + if "discordId" in values: + self._discord_id = int(values["discordId"]) if "name" in values: self._name = values["name"] diff --git a/kdb-bot/src/bot_graphql/filter/sort.py b/kdb-bot/src/bot_graphql/filter/sort.py index cb431a39..f1c966dd 100644 --- a/kdb-bot/src/bot_graphql/filter/sort.py +++ b/kdb-bot/src/bot_graphql/filter/sort.py @@ -10,11 +10,11 @@ class Sort(FilterABC): self._sort_column = None def from_dict(self, values: dict): - if "sort_direction" in values: - self._sort_direction = values["sort_direction"] + if "sortDirection" in values: + self._sort_direction = values["sortDirection"] - if "sort_column" in values: - self._sort_column = values["sort_column"] + if "sortColumn" in values: + self._sort_column = values["sortColumn"] def filter(self, query: List, *args) -> List: return query diff --git a/kdb-bot/src/bot_graphql/filter/user_filter.py b/kdb-bot/src/bot_graphql/filter/user_filter.py index 5c6c3958..b0028674 100644 --- a/kdb-bot/src/bot_graphql/filter/user_filter.py +++ b/kdb-bot/src/bot_graphql/filter/user_filter.py @@ -37,8 +37,8 @@ class UserFilter(FilterABC): if "id" in values: self._id = int(values["id"]) - if "discord_id" in values: - self._discord_id = int(values["discord_id"]) + if "discordId" in values: + self._discord_id = int(values["discordId"]) if "name" in values: self._name = values["name"] diff --git a/kdb-bot/src/bot_graphql/filter/user_joined_server_filter.py b/kdb-bot/src/bot_graphql/filter/user_joined_server_filter.py index cdad13db..30af37fa 100644 --- a/kdb-bot/src/bot_graphql/filter/user_joined_server_filter.py +++ b/kdb-bot/src/bot_graphql/filter/user_joined_server_filter.py @@ -32,11 +32,11 @@ class UserJoinedServerFilter(FilterABC): self._user: UserFilter = self._services.get_service(UserFilter) self._user.from_dict(values["user"]) - if "joined_on" in values: - self._joined_on = values["joined_on"] + if "joinedOn" in values: + self._joined_on = values["joinedOn"] - if "leaved_on" in values: - self._leaved_on = values["leaved_on"] + if "leavedOn" in values: + self._leaved_on = values["leavedOn"] def filter(self, query: List[UserJoinedServer]) -> List[UserJoinedServer]: if self._id is not None: diff --git a/kdb-bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py b/kdb-bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py index 13a204a7..bdbddeab 100644 --- a/kdb-bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py +++ b/kdb-bot/src/bot_graphql/filter/user_joined_voice_channel_filter.py @@ -28,11 +28,11 @@ class UserJoinedVoiceChannelFilter(FilterABC): if "id" in values: self._id = int(values["id"]) - if "channel_id" in values: - self._channel_id = int(values["channel_id"]) + if "channelId" in values: + self._channel_id = int(values["channelId"]) - if "channel_name" in values: - self._channel_name = values["channel_name"] + if "channelName" in values: + self._channel_name = values["channelName"] if "user" in values: from bot_graphql.filter.user_filter import UserFilter @@ -40,11 +40,11 @@ class UserJoinedVoiceChannelFilter(FilterABC): self._user: UserFilter = self._services.get_service(UserFilter) self._user.from_dict(values["user"]) - if "joined_on" in values: - self._joined_on = values["joined_on"] + if "joinedOn" in values: + self._joined_on = values["joinedOn"] - if "leaved_on" in values: - self._leaved_on = values["leaved_on"] + if "leavedOn" in values: + self._leaved_on = values["leavedOn"] def filter(self, query: List[UserJoinedVoiceChannel]) -> List[UserJoinedVoiceChannel]: if self._id is not None: diff --git a/kdb-bot/src/bot_graphql/graphql_module.py b/kdb-bot/src/bot_graphql/graphql_module.py index 2ce333db..43da66e0 100644 --- a/kdb-bot/src/bot_graphql/graphql_module.py +++ b/kdb-bot/src/bot_graphql/graphql_module.py @@ -47,6 +47,8 @@ class GraphQLModule(ModuleABC): services.add_singleton(GraphQLService) services.add_singleton(Query) services.add_singleton(Mutation) + + # queries services.add_transient(QueryABC, AutoRoleQuery) services.add_transient(QueryABC, AutoRoleRuleQuery) services.add_transient(QueryABC, ClientQuery) @@ -57,6 +59,7 @@ class GraphQLModule(ModuleABC): services.add_transient(QueryABC, UserJoinedServerQuery) services.add_transient(QueryABC, UserJoinedVoiceChannelQuery) + # filters services.add_singleton(FilterABC, AutoRoleFilter) services.add_singleton(FilterABC, AutoRoleRuleFilter) services.add_singleton(FilterABC, ClientFilter) @@ -66,6 +69,7 @@ class GraphQLModule(ModuleABC): services.add_singleton(FilterABC, UserJoinedServerFilter) services.add_singleton(FilterABC, UserJoinedVoiceChannelFilter) + # mutations services.add_transient(QueryABC, AutoRoleMutation) services.add_transient(QueryABC, AutoRoleRuleMutation) services.add_transient(QueryABC, LevelMutation) diff --git a/kdb-bot/src/bot_graphql/model/autoRole.gql b/kdb-bot/src/bot_graphql/model/autoRole.gql new file mode 100644 index 00000000..2680e264 --- /dev/null +++ b/kdb-bot/src/bot_graphql/model/autoRole.gql @@ -0,0 +1,35 @@ +type AutoRole implements TableQuery { + id: ID + channelId: String + channelName: String + messageId: String + + server: Server + + autoRoleRuleCount: Int + autoRoleRules(filter: AutoRoleRuleFilter, page: Page, sort: Sort): [AutoRoleRule] + + createdAt: String + modifiedAt: String +} + +input AutoRoleFilter { + id: ID + channelId: String + channelName: String + messageId: String + server: ServerFilter +} + +type AutoRoleMutation { + createAutoRole(input: AutoRoleInput!): AutoRole + updateAutoRole(input: AutoRoleInput!): AutoRole + deleteAutoRole(id: ID): AutoRole +} + +input AutoRoleInput { + id: ID! + channelId: String! + messageId: String! + serverId: ID! +} \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/autoRoleRule.gql b/kdb-bot/src/bot_graphql/model/autoRoleRule.gql new file mode 100644 index 00000000..31e87177 --- /dev/null +++ b/kdb-bot/src/bot_graphql/model/autoRoleRule.gql @@ -0,0 +1,32 @@ +type AutoRoleRule implements TableQuery { + id: ID + emojiName: String + roleId: String + roleName: String + + autoRole: AutoRole + + createdAt: String + modifiedAt: String +} + +input AutoRoleRuleFilter { + id: ID + emojiName: String + roleId: String + roleName: String + autoRole: AutoRoleFilter +} + +type AutoRoleRuleMutation { + createAutoRoleRule(input: AutoRoleRuleInput!): AutoRoleRule + updateAutoRoleRule(input: AutoRoleRuleInput!): AutoRoleRule + deleteAutoRoleRule(id: ID): AutoRoleRule +} + +input AutoRoleRuleInput { + id: ID! + emojiName: String! + roleId: String! + autoRoleId: ID! +} \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/auto_role.gql b/kdb-bot/src/bot_graphql/model/auto_role.gql deleted file mode 100644 index a45c925c..00000000 --- a/kdb-bot/src/bot_graphql/model/auto_role.gql +++ /dev/null @@ -1,35 +0,0 @@ -type AutoRole implements TableQuery { - id: ID - channel_id: String - channel_name: String - message_id: String - - server: Server - - auto_role_rule_count: Int - auto_role_rules(filter: AutoRoleRuleFilter, page: Page, sort: Sort): [AutoRoleRule] - - created_at: String - modified_at: String -} - -input AutoRoleFilter { - id: ID - channel_id: String - channel_name: String - message_id: String - server: ServerFilter -} - -type AutoRoleMutation { - create_auto_role(input: AutoRoleInput!): AutoRole - update_auto_role(input: AutoRoleInput!): AutoRole - delete_auto_role(id: ID): AutoRole -} - -input AutoRoleInput { - id: ID! - channel_id: String! - message_id: String! - server_id: ID! -} \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/auto_role_rule.gql b/kdb-bot/src/bot_graphql/model/auto_role_rule.gql deleted file mode 100644 index 18460656..00000000 --- a/kdb-bot/src/bot_graphql/model/auto_role_rule.gql +++ /dev/null @@ -1,32 +0,0 @@ -type AutoRoleRule implements TableQuery { - id: ID - emoji_name: String - role_id: String - role_name: String - - auto_role: AutoRole - - created_at: String - modified_at: String -} - -input AutoRoleRuleFilter { - id: ID - emoji_name: String - role_id: String - role_name: String - auto_role: AutoRoleFilter -} - -type AutoRoleRuleMutation { - create_auto_role_rule(input: AutoRoleRuleInput!): AutoRoleRule - update_auto_role_rule(input: AutoRoleRuleInput!): AutoRoleRule - delete_auto_role_rule(id: ID): AutoRoleRule -} - -input AutoRoleRuleInput { - id: ID! - emoji_name: String! - role_id: String! - auto_role_id: ID! -} \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/base.gql b/kdb-bot/src/bot_graphql/model/base.gql index b2babd53..1ae03045 100644 --- a/kdb-bot/src/bot_graphql/model/base.gql +++ b/kdb-bot/src/bot_graphql/model/base.gql @@ -1,14 +1,14 @@ interface TableQuery { - created_at: String - modified_at: String + createdAt: String + modifiedAt: String } input Page { - page_index: Int - page_size: Int + pageIndex: Int + pageSize: Int } input Sort { - sort_direction: String - sort_column: String + sortDirection: String + sortColumn: String } \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/client.gql b/kdb-bot/src/bot_graphql/model/client.gql index 284ca0d6..8afc7c73 100644 --- a/kdb-bot/src/bot_graphql/model/client.gql +++ b/kdb-bot/src/bot_graphql/model/client.gql @@ -1,22 +1,22 @@ type Client implements TableQuery { id: ID - discord_id: String + discordId: String name: String - sent_message_count: Int - received_message_count: Int - deleted_message_count: Int - received_command_count: Int - moved_users_count: Int + sentMessageCount: Int + receivedMessageCount: Int + deletedMessageCount: Int + receivedCommandCount: Int + movedUsersCount: Int server: Server - created_at: String - modified_at: String + createdAt: String + modifiedAt: String } input ClientFilter { id: ID - discord_id: String + discordId: String name: String server: ServerFilter } \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/knownUser.gql b/kdb-bot/src/bot_graphql/model/knownUser.gql new file mode 100644 index 00000000..bb96cd3d --- /dev/null +++ b/kdb-bot/src/bot_graphql/model/knownUser.gql @@ -0,0 +1,7 @@ +type KnownUser implements TableQuery { + id: ID + discordId: String + + createdAt: String + modifiedAt: String +} \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/known_user.gql b/kdb-bot/src/bot_graphql/model/known_user.gql deleted file mode 100644 index fac127c0..00000000 --- a/kdb-bot/src/bot_graphql/model/known_user.gql +++ /dev/null @@ -1,7 +0,0 @@ -type KnownUser implements TableQuery { - id: ID - discord_id: String - - created_at: String - modified_at: String -} \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/level.gql b/kdb-bot/src/bot_graphql/model/level.gql index cae1e3ab..93081b7f 100644 --- a/kdb-bot/src/bot_graphql/model/level.gql +++ b/kdb-bot/src/bot_graphql/model/level.gql @@ -2,13 +2,13 @@ type Level implements TableQuery { id: ID name: String color: String - min_xp: Int + minXp: Int permissions: String server: Server - created_at: String - modified_at: String + createdAt: String + modifiedAt: String } input LevelFilter { @@ -18,16 +18,16 @@ input LevelFilter { } type LevelMutation { - create_level(input: LevelInput!): Level - update_level(input: LevelInput!): Level - delete_level(id: ID): Level + createLevel(input: LevelInput!): Level + updateLevel(input: LevelInput!): Level + deleteLevel(id: ID): Level } input LevelInput { id: ID name: String! color: String! - min_xp: Int! + minXp: Int! permissions: String! - server_id: ID! + serverId: ID! } \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/mutation.gql b/kdb-bot/src/bot_graphql/model/mutation.gql index 1eee7819..5290dd1c 100644 --- a/kdb-bot/src/bot_graphql/model/mutation.gql +++ b/kdb-bot/src/bot_graphql/model/mutation.gql @@ -1,6 +1,6 @@ type Mutation { - auto_role: AutoRoleMutation - auto_role_rule: AutoRoleRuleMutation + autoRole: AutoRoleMutation + autoRoleRule: AutoRoleRuleMutation level: LevelMutation user: UserMutation } \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/query.gql b/kdb-bot/src/bot_graphql/model/query.gql index 02a63479..c28c5c6d 100644 --- a/kdb-bot/src/bot_graphql/model/query.gql +++ b/kdb-bot/src/bot_graphql/model/query.gql @@ -1,28 +1,28 @@ type Query { - auto_roles(filter: AutoRoleFilter, page: Page, sort: Sort): [AutoRole] - auto_role_count: Int + autoRoles(filter: AutoRoleFilter, page: Page, sort: Sort): [AutoRole] + autoRole_count: Int - auto_role_rules(filter: AutoRoleRuleFilter, page: Page, sort: Sort): [AutoRoleRule] - auto_role_rule_count: Int + autoRoleRules(filter: AutoRoleRuleFilter, page: Page, sort: Sort): [AutoRoleRule] + autoRoleRuleCount: Int clients(filter: ClientFilter, page: Page, sort: Sort): [Client] - client_count: Int + clientCount: Int - known_users: [KnownUser] - known_user_count: Int + knownUsers: [KnownUser] + knownUserCount: Int levels(filter: LevelFilter, page: Page, sort: Sort): [Level] - level_count: Int + levelCount: Int servers(filter: ServerFilter, page: Page, sort: Sort): [Server] - server_count: Int + serverCount: Int - user_joined_servers(filter: UserJoinedServerFilter, page: Page, sort: Sort): [User] - user_joined_server_count: Int + userJoinedServers(filter: UserJoinedServerFilter, page: Page, sort: Sort): [User] + userJoinedServerCount: Int - user_joined_voice_channels(filter: UserJoinedVoiceChannelFilter, page: Page, sort: Sort): [User] - user_joined_voice_channel_count: Int + userJoinedVoiceChannels(filter: UserJoinedVoiceChannelFilter, page: Page, sort: Sort): [User] + userJoinedVoiceChannelCount: Int users(filter: UserFilter, page: Page, sort: Sort): [User] - user_count: Int + userCount: Int } \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/server.gql b/kdb-bot/src/bot_graphql/model/server.gql index f3543fd3..659287f7 100644 --- a/kdb-bot/src/bot_graphql/model/server.gql +++ b/kdb-bot/src/bot_graphql/model/server.gql @@ -1,26 +1,26 @@ type Server implements TableQuery { id: ID - discord_id: String + discordId: String name: String - auto_roles(filter: AutoRoleFilter, page: Page, sort: Sort): [AutoRole] - auto_role_count: Int + autoRoles(filter: AutoRoleFilter, page: Page, sort: Sort): [AutoRole] + autoRoleCount: Int clients(filter: ClientFilter, page: Page, sort: Sort): [Client] - client_count: Int - - users(filter: UserFilter, page: Page, sort: Sort): [User] - user_count: Int + clientCount: Int levels(filter: LevelFilter, page: Page, sort: Sort): [Level] - level_count: Int + levelCount: Int - created_at: String - modified_at: String + users(filter: UserFilter, page: Page, sort: Sort): [User] + userCount: Int + + createdAt: String + modifiedAt: String } input ServerFilter { id: ID - discord_id: String + discordId: String name: String } \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/user.gql b/kdb-bot/src/bot_graphql/model/user.gql index e175dab5..6d0ad93a 100644 --- a/kdb-bot/src/bot_graphql/model/user.gql +++ b/kdb-bot/src/bot_graphql/model/user.gql @@ -1,26 +1,26 @@ type User implements TableQuery { id: ID - discord_id: String + discordId: String name: String xp: Int ontime: Float level: Level - joined_servers(filter: UserJoinedServerFilter, page: Page, sort: Sort): [UserJoinedServer] - joined_server_count: Int + joinedServers(filter: UserJoinedServerFilter, page: Page, sort: Sort): [UserJoinedServer] + joinedServerCount: Int - joined_voice_channels(filter: UserJoinedVoiceChannelFilter, page: Page, sort: Sort): [UserJoinedVoiceChannel] - joined_voice_channel_count: Int + joinedVoiceChannels(filter: UserJoinedVoiceChannelFilter, page: Page, sort: Sort): [UserJoinedVoiceChannel] + joinedVoiceChannelCount: Int server: Server - created_at: String - modified_at: String + createdAt: String + modifiedAt: String } input UserFilter { id: ID - discord_id: String + discordId: String name: String xp: Int ontime: Float @@ -29,7 +29,7 @@ input UserFilter { } type UserMutation { - update_user(input: UserInput!): User + updateUser(input: UserInput!): User } input UserInput { diff --git a/kdb-bot/src/bot_graphql/model/user_joined_server.gql b/kdb-bot/src/bot_graphql/model/userJoinedServer.gql similarity index 51% rename from kdb-bot/src/bot_graphql/model/user_joined_server.gql rename to kdb-bot/src/bot_graphql/model/userJoinedServer.gql index 05cda1b5..a8cbb343 100644 --- a/kdb-bot/src/bot_graphql/model/user_joined_server.gql +++ b/kdb-bot/src/bot_graphql/model/userJoinedServer.gql @@ -1,16 +1,16 @@ type UserJoinedServer implements TableQuery { id: ID user: User - joined_on: String - leaved_on: String + joinedOn: String + leavedOn: String - created_at: String - modified_at: String + createdAt: String + modifiedAt: String } input UserJoinedServerFilter { id: ID user: UserFilter - joined_on: String - leaved_on: String + joinedOn: String + leavedOn: String } \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/userJoinedVoiceChannel.gql b/kdb-bot/src/bot_graphql/model/userJoinedVoiceChannel.gql new file mode 100644 index 00000000..d49f8c9e --- /dev/null +++ b/kdb-bot/src/bot_graphql/model/userJoinedVoiceChannel.gql @@ -0,0 +1,20 @@ +type UserJoinedVoiceChannel implements TableQuery { + id: ID + channelId: String + channelName: String + user: User + joinedOn: String + leavedOn: String + + createdAt: String + modifiedAt: String +} + +input UserJoinedVoiceChannelFilter { + id: ID + channelId: String + channelName: String + user: UserFilter + joinedOn: String + leavedOn: String +} \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/model/user_joined_voice_channel.gql b/kdb-bot/src/bot_graphql/model/user_joined_voice_channel.gql deleted file mode 100644 index 51f90c53..00000000 --- a/kdb-bot/src/bot_graphql/model/user_joined_voice_channel.gql +++ /dev/null @@ -1,20 +0,0 @@ -type UserJoinedVoiceChannel implements TableQuery { - id: ID - channel_id: String - channel_name: String - user: User - joined_on: String - leaved_on: String - - created_at: String - modified_at: String -} - -input UserJoinedVoiceChannelFilter { - id: ID - channel_id: String - channel_name: String - user: UserFilter - joined_on: String - leaved_on: String -} \ No newline at end of file diff --git a/kdb-bot/src/bot_graphql/mutation.py b/kdb-bot/src/bot_graphql/mutation.py index 079dd104..5b980c14 100644 --- a/kdb-bot/src/bot_graphql/mutation.py +++ b/kdb-bot/src/bot_graphql/mutation.py @@ -1,14 +1,39 @@ from ariadne import MutationType +from bot_graphql.mutations.auto_role_mutation import AutoRoleMutation +from bot_graphql.mutations.auto_role_rule_mutation import AutoRoleRuleMutation from bot_graphql.mutations.level_mutation import LevelMutation +from bot_graphql.mutations.user_mutation import UserMutation class Mutation(MutationType): - def __init__(self, level_mutation: LevelMutation): + def __init__( + self, + auto_role_mutation: AutoRoleMutation, + auto_role_rule_mutation: AutoRoleRuleMutation, + level_mutation: LevelMutation, + user_mutation: UserMutation, + ): MutationType.__init__(self) + self._auto_role_mutation = auto_role_mutation + self._auto_role_rule_mutation = auto_role_rule_mutation self._level_mutation = level_mutation + self._user_mutation = user_mutation + + self.set_field("autoRole", self.resolve_auto_role) + self.set_field("autoRoleRule", self.resolve_auto_role_rule) self.set_field("level", self.resolve_level) + self.set_field("user", self.resolve_user) + + def resolve_auto_role(self, *_): + return self._auto_role_mutation + + def resolve_auto_role_rule(self, *_): + return self._auto_role_rule_mutation def resolve_level(self, *_): return self._level_mutation + + def resolve_user(self, *_): + return self._user_mutation diff --git a/kdb-bot/src/bot_graphql/mutations/auto_role_mutation.py b/kdb-bot/src/bot_graphql/mutations/auto_role_mutation.py index 29f999b2..b5a0cc40 100644 --- a/kdb-bot/src/bot_graphql/mutations/auto_role_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/auto_role_mutation.py @@ -19,30 +19,28 @@ class AutoRoleMutation(QueryABC): self._auto_roles = auto_roles self._db = db - self.set_field("create_auto_role", self.resolve_create_auto_role) - self.set_field("update_auto_role", self.resolve_update_auto_role) - self.set_field("delete_auto_role", self.resolve_delete_auto_role) + self.set_field("createAutoRole", self.resolve_create_auto_role) + self.set_field("updateAutoRole", self.resolve_update_auto_role) + self.set_field("deleteAutoRole", self.resolve_delete_auto_role) def resolve_create_auto_role(self, *_, input: dict): - auto_role = AutoRole( - self._servers.get_server_by_id(input["server_id"]), input["channel_id"], input["message_id"] - ) + auto_role = AutoRole(self._servers.get_server_by_id(input["serverId"]), input["channelId"], input["messageId"]) self._auto_roles.add_auto_role(auto_role) self._db.save_changes() def get_new(x: AutoRole): return ( - x.server.server_id == input["server_id"] - and x.discord_channel_id == input["channel_id"] - and x.discord_message_id == input["message_id"] + x.server.server_id == input["serverId"] + and x.discord_channel_id == input["channelId"] + and x.discord_message_id == input["messageId"] ) return self._auto_roles.get_auto_roles_by_server_id(auto_role.server.server_id).where(get_new) def resolve_update_auto_role(self, *_, input: dict): auto_role = self._auto_roles.get_auto_role_by_id(input["id"]) - auto_role.discord_channel_id = input["channel_id"] if "channel_id" in input else auto_role.discord_channel_id - auto_role.discord_message_id = input["message_id"] if "message_id" in input else auto_role.discord_message_id + auto_role.discord_channel_id = input["channelId"] if "channelId" in input else auto_role.discord_channel_id + auto_role.discord_message_id = input["messageId"] if "messageId" in input else auto_role.discord_message_id self._auto_roles.update_auto_role(auto_role) self._db.save_changes() diff --git a/kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py b/kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py index 37052692..89ed0669 100644 --- a/kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/auto_role_rule_mutation.py @@ -19,22 +19,22 @@ class AutoRoleRuleMutation(QueryABC): self._auto_roles = auto_roles self._db = db - self.set_field("create_auto_role_rule", self.resolve_create_auto_role_rule) - self.set_field("update_auto_role_rule", self.resolve_update_auto_role_rule) - self.set_field("delete_auto_role_rule", self.resolve_delete_auto_role_rule) + self.set_field("createAutoRoleRule", self.resolve_create_auto_role_rule) + self.set_field("updateAutoRoleRule", self.resolve_update_auto_role_rule) + self.set_field("deleteAutoRoleRule", self.resolve_delete_auto_role_rule) def resolve_create_auto_role_rule(self, *_, input: dict): auto_role_rule = AutoRoleRule( - self._auto_roles.get_auto_role_by_id(input["auto_role_id"]), input["emoji_name"], input["role_id"] + self._auto_roles.get_auto_role_by_id(input["autoRoleId"]), input["emojiName"], input["roleId"] ) self._auto_roles.add_auto_role_rule(auto_role_rule) self._db.save_changes() def get_new(x: AutoRoleRule): return ( - x.auto_role.auto_role_id == input["auto_role_id"] - and x.emoji_name == input["emoji_name"] - and x.role_id == input["role_id"] + x.auto_role.auto_role_id == input["autoRoleId"] + and x.emoji_name == input["emojiName"] + and x.role_id == input["roleId"] ) return self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role_rule.auto_role.auto_role_id).where( @@ -43,8 +43,8 @@ class AutoRoleRuleMutation(QueryABC): def resolve_update_auto_role_rule(self, *_, input: dict): auto_role_rule = self._auto_roles.get_auto_role_rule_by_id(input["id"]) - auto_role_rule.emoji_name = input["emoji_name"] if "emoji_name" in input else auto_role_rule.emoji_name - auto_role_rule.role_id = input["role_id"] if "role_id" in input else auto_role_rule.role_id + auto_role_rule.emoji_name = input["emojiName"] if "emojiName" in input else auto_role_rule.emoji_name + auto_role_rule.role_id = input["roleId"] if "roleId" in input else auto_role_rule.role_id self._auto_roles.update_auto_role_rule(auto_role_rule) self._db.save_changes() diff --git a/kdb-bot/src/bot_graphql/mutations/level_mutation.py b/kdb-bot/src/bot_graphql/mutations/level_mutation.py index dd9681fc..15940a4f 100644 --- a/kdb-bot/src/bot_graphql/mutations/level_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/level_mutation.py @@ -19,17 +19,17 @@ class LevelMutation(QueryABC): self._levels = levels self._db = db - self.set_field("create_level", self.resolve_create_level) - self.set_field("update_level", self.resolve_update_level) - self.set_field("delete_level", self.resolve_delete_level) + self.set_field("createLevel", self.resolve_create_level) + self.set_field("updateLevel", self.resolve_update_level) + self.set_field("deleteLevel", self.resolve_delete_level) def resolve_create_level(self, *_, input: dict): level = Level( input["name"], input["color"], - int(input["min_xp"]), + int(input["minXp"]), int(input["permissions"]), - self._servers.get_server_by_id(input["server_id"]), + self._servers.get_server_by_id(input["serverId"]), ) self._levels.add_level(level) self._db.save_changes() @@ -48,7 +48,7 @@ class LevelMutation(QueryABC): level = self._levels.get_level_by_id(input["id"]) level.name = input["name"] if "name" in input else level.name level.color = input["color"] if "color" in input else level.color - level.min_xp = input["min_xp"] if "min_xp" in input else level.min_xp + level.min_xp = input["minXp"] if "minXp" in input else level.min_xp level.permissions = input["permissions"] if "permissions" in input else level.permissions self._levels.update_level(level) diff --git a/kdb-bot/src/bot_graphql/mutations/user_mutation.py b/kdb-bot/src/bot_graphql/mutations/user_mutation.py index 38ef276e..1e90cd83 100644 --- a/kdb-bot/src/bot_graphql/mutations/user_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/user_mutation.py @@ -18,7 +18,7 @@ class UserMutation(QueryABC): self._users = users self._db = db - self.set_field("update_user", self.resolve_update_user) + self.set_field("updateUser", self.resolve_update_user) def resolve_update_user(self, *_, input: dict): user = self._users.get_user_by_id(input["id"]) diff --git a/kdb-bot/src/bot_graphql/queries/auto_role_query.py b/kdb-bot/src/bot_graphql/queries/auto_role_query.py index 16ecfe65..53a2b97c 100644 --- a/kdb-bot/src/bot_graphql/queries/auto_role_query.py +++ b/kdb-bot/src/bot_graphql/queries/auto_role_query.py @@ -21,12 +21,12 @@ class AutoRoleQuery(DataQueryABC): self._servers = servers self.set_field("id", self.resolve_id) - self.set_field("channel_id", self.resolve_channel_id) - self.set_field("channel_name", self.resolve_channel_name) - self.set_field("message_id", self.resolve_message_id) + self.set_field("channelId", self.resolve_channel_id) + self.set_field("channelName", self.resolve_channel_name) + self.set_field("messageId", self.resolve_message_id) self.set_field("server", self.resolve_server) self.add_collection( - "auto_role_rule", lambda x, *_: self._auto_role_rules.get_auto_role_rules_by_auto_role_id(x.auto_role_id) + "autoRoleRule", lambda x, *_: self._auto_role_rules.get_auto_role_rules_by_auto_role_id(x.auto_role_id) ) @staticmethod diff --git a/kdb-bot/src/bot_graphql/queries/auto_role_rule_query.py b/kdb-bot/src/bot_graphql/queries/auto_role_rule_query.py index 943e4d8e..5103aec4 100644 --- a/kdb-bot/src/bot_graphql/queries/auto_role_rule_query.py +++ b/kdb-bot/src/bot_graphql/queries/auto_role_rule_query.py @@ -17,10 +17,10 @@ class AutoRoleRuleQuery(DataQueryABC): self._auto_roles = auto_roles self.set_field("id", self.resolve_id) - self.set_field("emoji_name", self.resolve_emoji_name) - self.set_field("role_id", self.resolve_role_id) - self.set_field("role_name", self.resolve_role_name) - self.set_field("auto_role", self.resolve_auto_role) + self.set_field("emojiName", self.resolve_emoji_name) + self.set_field("roleId", self.resolve_role_id) + self.set_field("roleName", self.resolve_role_name) + self.set_field("autoRole", self.resolve_auto_role) @staticmethod def resolve_id(x: AutoRoleRule, *_): diff --git a/kdb-bot/src/bot_graphql/queries/client_query.py b/kdb-bot/src/bot_graphql/queries/client_query.py index 6460dc54..824afa9b 100644 --- a/kdb-bot/src/bot_graphql/queries/client_query.py +++ b/kdb-bot/src/bot_graphql/queries/client_query.py @@ -14,13 +14,13 @@ class ClientQuery(DataQueryABC): self._bot = bot self.set_field("id", self.resolve_id) - self.set_field("discord_id", self.resolve_discord_id) + self.set_field("discordId", self.resolve_discord_id) self.set_field("name", self.resolve_name) - self.set_field("sent_message_count", self.resolve_sent_message_count) - self.set_field("received_message_count", self.resolve_received_message_count) - self.set_field("deleted_message_count", self.resolve_deleted_message_count) - self.set_field("received_command_count", self.resolve_received_command_count) - self.set_field("moved_users_count", self.resolve_moved_users_count) + self.set_field("sentMessageCount", self.resolve_sent_message_count) + self.set_field("receivedMessageCount", self.resolve_received_message_count) + self.set_field("deletedMessageCount", self.resolve_deleted_message_count) + self.set_field("receivedCommandCount", self.resolve_received_command_count) + self.set_field("movedUsersCount", self.resolve_moved_users_count) self.set_field("server", self.resolve_server) @staticmethod diff --git a/kdb-bot/src/bot_graphql/queries/known_user_query.py b/kdb-bot/src/bot_graphql/queries/known_user_query.py index 4de78ba7..243a6745 100644 --- a/kdb-bot/src/bot_graphql/queries/known_user_query.py +++ b/kdb-bot/src/bot_graphql/queries/known_user_query.py @@ -7,7 +7,7 @@ class KnownUserQuery(DataQueryABC): DataQueryABC.__init__(self, "KnownUser") self.set_field("id", self.resolve_id) - self.set_field("discord_id", self.resolve_discord_id) + self.set_field("discordId", self.resolve_discord_id) @staticmethod def resolve_id(x: KnownUser, *_): diff --git a/kdb-bot/src/bot_graphql/queries/level_query.py b/kdb-bot/src/bot_graphql/queries/level_query.py index bf492895..a0f22453 100644 --- a/kdb-bot/src/bot_graphql/queries/level_query.py +++ b/kdb-bot/src/bot_graphql/queries/level_query.py @@ -9,7 +9,7 @@ class LevelQuery(DataQueryABC): self.set_field("id", self.resolve_id) self.set_field("name", self.resolve_name) self.set_field("color", self.resolve_color) - self.set_field("min_xp", self.resolve_min_xp) + self.set_field("minXp", self.resolve_min_xp) self.set_field("permissions", self.resolve_permissions) self.set_field("server", self.resolve_server) diff --git a/kdb-bot/src/bot_graphql/queries/server_query.py b/kdb-bot/src/bot_graphql/queries/server_query.py index ed817290..88dfe324 100644 --- a/kdb-bot/src/bot_graphql/queries/server_query.py +++ b/kdb-bot/src/bot_graphql/queries/server_query.py @@ -3,6 +3,8 @@ from cpl_discord.service import DiscordBotServiceABC from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC from bot_data.abc.client_repository_abc import ClientRepositoryABC from bot_data.abc.level_repository_abc import LevelRepositoryABC +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_repository_abc import UserRepositoryABC from bot_data.model.server import Server from bot_graphql.abc.data_query_abc import DataQueryABC @@ -15,28 +17,31 @@ class ServerQuery(DataQueryABC): bot: DiscordBotServiceABC, auto_roles: AutoRoleRepositoryABC, clients: ClientRepositoryABC, - users: UserRepositoryABC, levels: LevelRepositoryABC, + users: UserRepositoryABC, + ujs: UserJoinedServerRepositoryABC, + ujvs: UserJoinedVoiceChannelRepositoryABC, ): DataQueryABC.__init__(self, "Server") self._bot = bot self._auto_roles = auto_roles - self._users = users self._clients = clients - self._users = users self._levels = levels + self._users = users + self._ujs = ujs + self._ujvs = ujvs self.set_field("id", self.resolve_id) - self.set_field("discord_id", self.resolve_discord_id) + self.set_field("discordId", self.resolve_discord_id) self.set_field("name", self.resolve_name) self.add_collection( "auto_role", lambda server, *_: self._auto_roles.get_auto_roles_by_server_id(server.server_id) ) self.add_collection("client", lambda server, *_: self._clients.get_clients_by_server_id(server.server_id)) - self.add_collection("user", lambda server, *_: self._users.get_users_by_server_id(server.server_id), UserFilter) self.add_collection("level", lambda server, *_: self._levels.get_levels_by_server_id(server.server_id)) + self.add_collection("user", lambda server, *_: self._users.get_users_by_server_id(server.server_id), UserFilter) @staticmethod def resolve_id(server: Server, *_): diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_server_query.py b/kdb-bot/src/bot_graphql/queries/user_joined_server_query.py index 775ecdfc..db18781a 100644 --- a/kdb-bot/src/bot_graphql/queries/user_joined_server_query.py +++ b/kdb-bot/src/bot_graphql/queries/user_joined_server_query.py @@ -8,8 +8,8 @@ class UserJoinedServerQuery(DataQueryABC): self.set_field("id", self.resolve_id) self.set_field("user", self.resolve_user) - self.set_field("joined_on", self.resolve_joined_on) - self.set_field("leaved_on", self.resolve_leaved_on) + self.set_field("joinedOn", self.resolve_joined_on) + self.set_field("leavedOn", self.resolve_leaved_on) @staticmethod def resolve_id(x: UserJoinedServer, *_): diff --git a/kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_query.py b/kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_query.py index 46790973..99bcc0c3 100644 --- a/kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_query.py +++ b/kdb-bot/src/bot_graphql/queries/user_joined_voice_channel_query.py @@ -11,11 +11,11 @@ class UserJoinedVoiceChannelQuery(DataQueryABC): self._bot = bot self.set_field("id", self.resolve_id) - self.set_field("channel_id", self.resolve_channel_id) - self.set_field("channel_name", self.resolve_channel_name) + self.set_field("channelId", self.resolve_channel_id) + self.set_field("channelName", self.resolve_channel_name) self.set_field("user", self.resolve_user) - self.set_field("joined_on", self.resolve_joined_on) - self.set_field("leaved_on", self.resolve_leaved_on) + self.set_field("joinedOn", self.resolve_joined_on) + self.set_field("leavedOn", self.resolve_leaved_on) @staticmethod def resolve_id(x: UserJoinedVoiceChannel, *_): diff --git a/kdb-bot/src/bot_graphql/queries/user_query.py b/kdb-bot/src/bot_graphql/queries/user_query.py index 17d8e04d..7bca0379 100644 --- a/kdb-bot/src/bot_graphql/queries/user_query.py +++ b/kdb-bot/src/bot_graphql/queries/user_query.py @@ -26,16 +26,14 @@ class UserQuery(DataQueryABC): self._ujvs = ujvs self.set_field("id", self.resolve_id) - self.set_field("discord_id", self.resolve_discord_id) + 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("ontime", self.resolve_ontime) self.set_field("level", self.resolve_level) + self.add_collection("joinedServer", lambda user, *_: self._ujs.get_user_joined_servers_by_user_id(user.user_id)) self.add_collection( - "joined_server", lambda user, *_: self._ujs.get_user_joined_servers_by_user_id(user.user_id) - ) - self.add_collection( - "joined_voice_channel", lambda user, *_: self._ujvs.get_user_joined_voice_channels_by_user_id(user.user_id) + "joinedVoiceChannel", lambda user, *_: self._ujvs.get_user_joined_voice_channels_by_user_id(user.user_id) ) self.set_field("server", self.resolve_server) diff --git a/kdb-bot/src/bot_graphql/query.py b/kdb-bot/src/bot_graphql/query.py index 687aafc4..e5fd5803 100644 --- a/kdb-bot/src/bot_graphql/query.py +++ b/kdb-bot/src/bot_graphql/query.py @@ -36,14 +36,14 @@ class Query(QueryABC): self._user_joined_voice_channels = user_joined_voice_channel self._users = users - self.add_collection("auto_role", lambda *_: self._auto_roles.get_auto_roles(), AutoRoleFilter) - self.add_collection("auto_role_rule", lambda *_: self._auto_roles.get_auto_role_rules(), AutoRoleRuleFilter) + self.add_collection("autoRole", lambda *_: self._auto_roles.get_auto_roles(), AutoRoleFilter) + self.add_collection("autoRoleRule", lambda *_: self._auto_roles.get_auto_role_rules(), AutoRoleRuleFilter) self.add_collection("client", lambda *_: self._clients.get_clients()) - self.add_collection("known_user", lambda *_: self._known_users.get_users()) + self.add_collection("knowUser", lambda *_: self._known_users.get_users()) self.add_collection("level", lambda *_: self._levels.get_levels(), LevelFilter) self.add_collection("server", lambda *_: self._servers.get_servers(), ServerFilter) - self.add_collection("user_joined_server", lambda *_: self._user_joined_servers.get_user_joined_servers()) + self.add_collection("userJoinedServer", lambda *_: self._user_joined_servers.get_user_joined_servers()) self.add_collection( - "user_joined_voice_channel", lambda *_: self._user_joined_voice_channels.get_user_joined_voice_channels() + "userJoinedVoiceChannel", lambda *_: self._user_joined_voice_channels.get_user_joined_voice_channels() ) self.add_collection("user", lambda *_: self._users.get_users(), UserFilter)