Added history tables to graphql #246
This commit is contained in:
parent
325a17b5a8
commit
69ce659328
49
kdb-bot/src/bot_data/model/auto_role_history.py
Normal file
49
kdb-bot/src/bot_data/model/auto_role_history.py
Normal file
@ -0,0 +1,49 @@
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||
|
||||
|
||||
class AutoRoleHistory(HistoryTableABC):
|
||||
def __init__(
|
||||
self,
|
||||
server: int,
|
||||
channel_id: int,
|
||||
dc_message_id: int,
|
||||
deleted: bool,
|
||||
date_from: str,
|
||||
date_to: str,
|
||||
id=0,
|
||||
):
|
||||
HistoryTableABC.__init__(self)
|
||||
|
||||
self._auto_role_id = id
|
||||
self._server = server
|
||||
self._discord_channel_id = channel_id
|
||||
self._discord_message_id = dc_message_id
|
||||
|
||||
self._deleted = deleted
|
||||
self._date_from = date_from
|
||||
self._date_to = date_to
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._auto_role_id
|
||||
|
||||
@property
|
||||
def server(self) -> int:
|
||||
return self._server
|
||||
|
||||
@property
|
||||
def discord_channel_id(self) -> int:
|
||||
return self._discord_channel_id
|
||||
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def discord_channel_name(self, bot: DiscordBotServiceABC) -> str:
|
||||
channel = bot.get_channel(self.discord_channel_id)
|
||||
return None if channel is None else channel.name
|
||||
|
||||
@property
|
||||
def discord_message_id(self) -> int:
|
||||
return self._discord_message_id
|
48
kdb-bot/src/bot_data/model/auto_role_rule_history.py
Normal file
48
kdb-bot/src/bot_data/model/auto_role_rule_history.py
Normal file
@ -0,0 +1,48 @@
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||
|
||||
|
||||
class AutoRoleRuleHistory(HistoryTableABC):
|
||||
def __init__(
|
||||
self,
|
||||
auto_role: int,
|
||||
discord_emoji_name: str,
|
||||
discord_role_id: int,
|
||||
deleted: bool,
|
||||
date_from: str,
|
||||
date_to: str,
|
||||
id=0,
|
||||
):
|
||||
HistoryTableABC.__init__(self)
|
||||
self._auto_role_rule_id = id
|
||||
self._auto_role = auto_role
|
||||
self._discord_emoji_name = discord_emoji_name
|
||||
self._discord_role_id = discord_role_id
|
||||
|
||||
self._deleted = deleted
|
||||
self._date_from = date_from
|
||||
self._date_to = date_to
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._auto_role_rule_id
|
||||
|
||||
@property
|
||||
def auto_role(self) -> int:
|
||||
return self._auto_role
|
||||
|
||||
@property
|
||||
def emoji_name(self) -> str:
|
||||
return self._discord_emoji_name
|
||||
|
||||
@property
|
||||
def role_id(self) -> int:
|
||||
return self._discord_role_id
|
||||
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def role_name(self, bot: DiscordBotServiceABC) -> str:
|
||||
guild = bot.get_guild(self.auto_role.server.discord_id)
|
||||
return guild.get_role(self.role_id).name
|
72
kdb-bot/src/bot_data/model/client_history.py
Normal file
72
kdb-bot/src/bot_data/model/client_history.py
Normal file
@ -0,0 +1,72 @@
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||
|
||||
|
||||
class ClientHistory(HistoryTableABC):
|
||||
def __init__(
|
||||
self,
|
||||
dc_id: int,
|
||||
smc: int,
|
||||
rmc: int,
|
||||
dmc: int,
|
||||
rcc: int,
|
||||
muc: int,
|
||||
server: int,
|
||||
deleted: bool,
|
||||
date_from: str,
|
||||
date_to: str,
|
||||
id=0,
|
||||
):
|
||||
HistoryTableABC.__init__(self)
|
||||
|
||||
self._client_id = id
|
||||
self._discord_client_id = dc_id
|
||||
self._sent_message_count = smc
|
||||
self._received_message_count = rmc
|
||||
self._deleted_message_count = dmc
|
||||
self._received_command_count = rcc
|
||||
self._moved_users_count = muc
|
||||
self._server = server
|
||||
|
||||
self._deleted = deleted
|
||||
self._date_from = date_from
|
||||
self._date_to = date_to
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._client_id
|
||||
|
||||
@property
|
||||
def discord_id(self) -> int:
|
||||
return self._discord_client_id
|
||||
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def name(self, bot: DiscordBotServiceABC) -> str:
|
||||
return bot.user.name
|
||||
|
||||
@property
|
||||
def sent_message_count(self) -> int:
|
||||
return self._sent_message_count
|
||||
|
||||
@property
|
||||
def received_message_count(self) -> int:
|
||||
return self._received_message_count
|
||||
|
||||
@property
|
||||
def deleted_message_count(self) -> int:
|
||||
return self._deleted_message_count
|
||||
|
||||
@property
|
||||
def received_command_count(self) -> int:
|
||||
return self._received_command_count
|
||||
|
||||
@property
|
||||
def moved_users_count(self) -> int:
|
||||
return self._moved_users_count
|
||||
|
||||
@property
|
||||
def server(self) -> int:
|
||||
return self._server
|
28
kdb-bot/src/bot_data/model/known_user_history.py
Normal file
28
kdb-bot/src/bot_data/model/known_user_history.py
Normal file
@ -0,0 +1,28 @@
|
||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||
|
||||
|
||||
class KnownUserHistory(HistoryTableABC):
|
||||
def __init__(
|
||||
self,
|
||||
dc_id: int,
|
||||
deleted: bool,
|
||||
date_from: str,
|
||||
date_to: str,
|
||||
id=0,
|
||||
):
|
||||
HistoryTableABC.__init__(self)
|
||||
|
||||
self._known_user_id = id
|
||||
self._discord_id = dc_id
|
||||
|
||||
self._deleted = deleted
|
||||
self._date_from = date_from
|
||||
self._date_to = date_to
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._known_user_id
|
||||
|
||||
@property
|
||||
def discord_id(self) -> int:
|
||||
return self._discord_id
|
@ -25,6 +25,7 @@ class LevelHistory(HistoryTableABC):
|
||||
self._min_xp = min_xp
|
||||
self._permissions = permissions
|
||||
self._server = server
|
||||
|
||||
self._deleted = deleted
|
||||
self._date_from = date_from
|
||||
self._date_to = date_to
|
||||
|
43
kdb-bot/src/bot_data/model/server_history.py
Normal file
43
kdb-bot/src/bot_data/model/server_history.py
Normal file
@ -0,0 +1,43 @@
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||
|
||||
|
||||
class ServerHistory(HistoryTableABC):
|
||||
def __init__(
|
||||
self,
|
||||
dc_id: int,
|
||||
deleted: bool,
|
||||
date_from: str,
|
||||
date_to: str,
|
||||
id=0,
|
||||
):
|
||||
HistoryTableABC.__init__(self)
|
||||
|
||||
self._server_id = id
|
||||
self._discord_server_id = dc_id
|
||||
|
||||
self._deleted = deleted
|
||||
self._date_from = date_from
|
||||
self._date_to = date_to
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._server_id
|
||||
|
||||
@property
|
||||
def discord_id(self) -> int:
|
||||
return self._discord_server_id
|
||||
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def name(self, bot: DiscordBotServiceABC) -> str:
|
||||
guild = bot.get_guild(self.discord_id)
|
||||
return None if guild is None else guild.name
|
||||
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def icon_url(self, bot: DiscordBotServiceABC) -> str:
|
||||
guild = bot.get_guild(self.discord_id)
|
||||
return None if guild is None else guild.icon.url
|
65
kdb-bot/src/bot_data/model/user_history.py
Normal file
65
kdb-bot/src/bot_data/model/user_history.py
Normal file
@ -0,0 +1,65 @@
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from cpl_query.extension import List
|
||||
|
||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||
|
||||
|
||||
class UserHistory(HistoryTableABC):
|
||||
def __init__(
|
||||
self,
|
||||
dc_id: int,
|
||||
xp: int,
|
||||
server: int,
|
||||
deleted: bool,
|
||||
date_from: str,
|
||||
date_to: str,
|
||||
id=0,
|
||||
):
|
||||
HistoryTableABC.__init__(self)
|
||||
|
||||
self._user_id = id
|
||||
self._discord_id = dc_id
|
||||
self._xp = xp
|
||||
self._server = server
|
||||
|
||||
self._deleted = deleted
|
||||
self._date_from = date_from
|
||||
self._date_to = date_to
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._user_id
|
||||
|
||||
@property
|
||||
def discord_id(self) -> int:
|
||||
return self._discord_id
|
||||
|
||||
@property
|
||||
def xp(self) -> int:
|
||||
return self._xp
|
||||
|
||||
@property
|
||||
def server(self) -> int:
|
||||
return self._server
|
||||
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def left_server(
|
||||
self,
|
||||
services: ServiceProviderABC,
|
||||
) -> bool:
|
||||
from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepositoryABC
|
||||
|
||||
ujs: UserJoinedServerRepositoryABC = services.get_service(UserJoinedServerRepositoryABC)
|
||||
return ujs.find_active_user_joined_server_by_user_id(self.id) is None
|
||||
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def game_idents(
|
||||
self,
|
||||
services: ServiceProviderABC,
|
||||
) -> List["UserGameIdent"]:
|
||||
from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryABC
|
||||
|
||||
game_idents_repo: UserGameIdentRepositoryABC = services.get_service(UserGameIdentRepositoryABC)
|
||||
return game_idents_repo.get_user_game_idents_by_user_id(self.id)
|
@ -0,0 +1,54 @@
|
||||
from datetime import datetime
|
||||
|
||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||
|
||||
|
||||
class UserJoinedGameServerHistory(HistoryTableABC):
|
||||
def __init__(
|
||||
self,
|
||||
user: int,
|
||||
game_server: int,
|
||||
joined_on: datetime,
|
||||
leaved_on: datetime,
|
||||
deleted: bool,
|
||||
date_from: str,
|
||||
date_to: str,
|
||||
id=0,
|
||||
):
|
||||
HistoryTableABC.__init__(self)
|
||||
|
||||
self._id = id
|
||||
self._user = user
|
||||
self._game_server = game_server
|
||||
self._joined_on = joined_on
|
||||
self._leaved_on = leaved_on
|
||||
|
||||
self._deleted = deleted
|
||||
self._date_from = date_from
|
||||
self._date_to = date_to
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def user(self) -> int:
|
||||
return self._user
|
||||
|
||||
@property
|
||||
def game_server(self) -> int:
|
||||
return self._game_server
|
||||
|
||||
@property
|
||||
def time(self) -> float:
|
||||
if self._leaved_on is None or self._joined_on is None:
|
||||
return 0
|
||||
return round((self.leaved_on - self.joined_on).total_seconds() / 3600, 2)
|
||||
|
||||
@property
|
||||
def joined_on(self) -> datetime:
|
||||
return self._joined_on
|
||||
|
||||
@property
|
||||
def leaved_on(self) -> datetime:
|
||||
return self._leaved_on
|
42
kdb-bot/src/bot_data/model/user_joined_server_history.py
Normal file
42
kdb-bot/src/bot_data/model/user_joined_server_history.py
Normal file
@ -0,0 +1,42 @@
|
||||
from datetime import datetime
|
||||
|
||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||
|
||||
|
||||
class UserJoinedServerHistory(HistoryTableABC):
|
||||
def __init__(
|
||||
self,
|
||||
user: int,
|
||||
joined_on: datetime,
|
||||
leaved_on: datetime,
|
||||
deleted: bool,
|
||||
date_from: str,
|
||||
date_to: str,
|
||||
id=0,
|
||||
):
|
||||
HistoryTableABC.__init__(self)
|
||||
|
||||
self._join_id = id
|
||||
self._user = user
|
||||
self._joined_on = joined_on
|
||||
self._leaved_on = leaved_on
|
||||
|
||||
self._deleted = deleted
|
||||
self._date_from = date_from
|
||||
self._date_to = date_to
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._join_id
|
||||
|
||||
@property
|
||||
def user(self) -> int:
|
||||
return self._user
|
||||
|
||||
@property
|
||||
def joined_on(self) -> datetime:
|
||||
return self._joined_on
|
||||
|
||||
@property
|
||||
def leaved_on(self) -> datetime:
|
||||
return self._leaved_on
|
@ -0,0 +1,62 @@
|
||||
from datetime import datetime
|
||||
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||
|
||||
|
||||
class UserJoinedVoiceChannelHistory(HistoryTableABC):
|
||||
def __init__(
|
||||
self,
|
||||
user: int,
|
||||
channel_id: int,
|
||||
joined_on: datetime,
|
||||
leaved_on: datetime,
|
||||
deleted: bool,
|
||||
date_from: str,
|
||||
date_to: str,
|
||||
id=0,
|
||||
):
|
||||
HistoryTableABC.__init__(self)
|
||||
|
||||
self._join_id = id
|
||||
self._channel_id = channel_id
|
||||
self._user = user
|
||||
self._joined_on = joined_on
|
||||
self._leaved_on = leaved_on
|
||||
|
||||
self._deleted = deleted
|
||||
self._date_from = date_from
|
||||
self._date_to = date_to
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._join_id
|
||||
|
||||
@property
|
||||
def channel_id(self) -> int:
|
||||
return self._channel_id
|
||||
|
||||
@property
|
||||
@ServiceProviderABC.inject
|
||||
def channel_name(self, bot: DiscordBotServiceABC) -> str:
|
||||
return bot.get_channel(self.channel_id).name
|
||||
|
||||
@property
|
||||
def user(self) -> int:
|
||||
return self._user
|
||||
|
||||
@property
|
||||
def time(self) -> float:
|
||||
if self._leaved_on is None or self._joined_on is None:
|
||||
return 0
|
||||
return round((self.leaved_on - self.joined_on).total_seconds() / 3600, 2)
|
||||
|
||||
@property
|
||||
def joined_on(self) -> datetime:
|
||||
return self._joined_on
|
||||
|
||||
@property
|
||||
def leaved_on(self) -> datetime:
|
||||
return self._leaved_on
|
10
kdb-bot/src/bot_graphql/abc/history_query_abc.py
Normal file
10
kdb-bot/src/bot_graphql/abc/history_query_abc.py
Normal file
@ -0,0 +1,10 @@
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
|
||||
|
||||
class HistoryQueryABC(QueryABC):
|
||||
def __init__(self, name: str):
|
||||
QueryABC.__init__(self, f"{name}History")
|
||||
|
||||
self.set_field("deleted", lambda x, *_: x.deleted)
|
||||
self.set_field("dateFrom", lambda x, *_: x.date_from)
|
||||
self.set_field("dateTo", lambda x, *_: x.date_to)
|
@ -24,15 +24,24 @@ from bot_graphql.mutations.auto_role_rule_mutation import AutoRoleRuleMutation
|
||||
from bot_graphql.mutations.level_mutation import LevelMutation
|
||||
from bot_graphql.mutations.user_joined_game_server_mutation import UserJoinedGameServerMutation
|
||||
from bot_graphql.mutations.user_mutation import UserMutation
|
||||
from bot_graphql.queries.auto_role_history_query import AutoRoleHistoryQuery
|
||||
from bot_graphql.queries.auto_role_query import AutoRoleQuery
|
||||
from bot_graphql.queries.auto_role_rule_history_query import AutoRoleRuleHistoryQuery
|
||||
from bot_graphql.queries.auto_role_rule_query import AutoRoleRuleQuery
|
||||
from bot_graphql.queries.client_history_query import ClientHistoryQuery
|
||||
from bot_graphql.queries.client_query import ClientQuery
|
||||
from bot_graphql.queries.known_user_history_query import KnownUserHistoryQuery
|
||||
from bot_graphql.queries.known_user_query import KnownUserQuery
|
||||
from bot_graphql.queries.level_history_query import LevelHistoryQuery
|
||||
from bot_graphql.queries.level_query import LevelQuery
|
||||
from bot_graphql.queries.server_history_query import ServerHistoryQuery
|
||||
from bot_graphql.queries.server_query import ServerQuery
|
||||
from bot_graphql.queries.user_history_query import UserHistoryQuery
|
||||
from bot_graphql.queries.user_joined_game_server_history_query import UserJoinedGameServerHistoryQuery
|
||||
from bot_graphql.queries.user_joined_game_server_query import UserJoinedGameServerQuery
|
||||
from bot_graphql.queries.user_joined_server_history_query import UserJoinedServerHistoryQuery
|
||||
from bot_graphql.queries.user_joined_server_query import UserJoinedServerQuery
|
||||
from bot_graphql.queries.user_joined_voice_channel_history_query import UserJoinedVoiceChannelHistoryQuery
|
||||
from bot_graphql.queries.user_joined_voice_channel_query import UserJoinedVoiceChannelQuery
|
||||
from bot_graphql.queries.user_query import UserQuery
|
||||
from bot_graphql.query import Query
|
||||
@ -53,16 +62,25 @@ class GraphQLModule(ModuleABC):
|
||||
services.add_singleton(Mutation)
|
||||
|
||||
# queries
|
||||
services.add_transient(QueryABC, AutoRoleHistoryQuery)
|
||||
services.add_transient(QueryABC, AutoRoleQuery)
|
||||
services.add_transient(QueryABC, AutoRoleRuleHistoryQuery)
|
||||
services.add_transient(QueryABC, AutoRoleRuleQuery)
|
||||
services.add_transient(QueryABC, ClientHistoryQuery)
|
||||
services.add_transient(QueryABC, ClientQuery)
|
||||
services.add_transient(QueryABC, KnownUserHistoryQuery)
|
||||
services.add_transient(QueryABC, KnownUserQuery)
|
||||
services.add_transient(QueryABC, LevelQuery)
|
||||
services.add_transient(QueryABC, LevelHistoryQuery)
|
||||
services.add_transient(QueryABC, LevelQuery)
|
||||
services.add_transient(QueryABC, ServerHistoryQuery)
|
||||
services.add_transient(QueryABC, ServerQuery)
|
||||
services.add_transient(QueryABC, UserHistoryQuery)
|
||||
services.add_transient(QueryABC, UserQuery)
|
||||
services.add_transient(QueryABC, UserJoinedServerHistoryQuery)
|
||||
services.add_transient(QueryABC, UserJoinedServerQuery)
|
||||
services.add_transient(QueryABC, UserJoinedVoiceChannelHistoryQuery)
|
||||
services.add_transient(QueryABC, UserJoinedVoiceChannelQuery)
|
||||
services.add_transient(QueryABC, UserJoinedGameServerHistoryQuery)
|
||||
services.add_transient(QueryABC, UserJoinedGameServerQuery)
|
||||
|
||||
# filters
|
||||
|
@ -1,4 +1,4 @@
|
||||
type AutoRole implements TableQuery {
|
||||
type AutoRole implements TableWithHistoryQuery {
|
||||
id: ID
|
||||
channelId: String
|
||||
channelName: String
|
||||
@ -11,6 +11,21 @@ type AutoRole implements TableQuery {
|
||||
|
||||
createdAt: String
|
||||
modifiedAt: String
|
||||
|
||||
history: [AutoRoleHistory]
|
||||
}
|
||||
|
||||
type AutoRoleHistory implements HistoryTableQuery {
|
||||
id: ID
|
||||
channelId: String
|
||||
channelName: String
|
||||
messageId: String
|
||||
|
||||
server: ID
|
||||
|
||||
deleted: Boolean
|
||||
dateFrom: String
|
||||
dateTo: String
|
||||
}
|
||||
|
||||
input AutoRoleFilter {
|
||||
|
@ -1,4 +1,4 @@
|
||||
type AutoRoleRule implements TableQuery {
|
||||
type AutoRoleRule implements TableWithHistoryQuery {
|
||||
id: ID
|
||||
emojiName: String
|
||||
roleId: String
|
||||
@ -8,6 +8,21 @@ type AutoRoleRule implements TableQuery {
|
||||
|
||||
createdAt: String
|
||||
modifiedAt: String
|
||||
|
||||
history: [AutoRoleRuleHistory]
|
||||
}
|
||||
|
||||
type AutoRoleRuleHistory implements HistoryTableQuery {
|
||||
id: ID
|
||||
emojiName: String
|
||||
roleId: String
|
||||
roleName: String
|
||||
|
||||
autoRole: ID
|
||||
|
||||
deleted: Boolean
|
||||
dateFrom: String
|
||||
dateTo: String
|
||||
}
|
||||
|
||||
input AutoRoleRuleFilter {
|
||||
|
@ -12,6 +12,25 @@ type Client implements TableQuery {
|
||||
|
||||
createdAt: String
|
||||
modifiedAt: String
|
||||
|
||||
history: [ClientHistory]
|
||||
}
|
||||
|
||||
type ClientHistory implements HistoryTableQuery {
|
||||
id: ID
|
||||
discordId: String
|
||||
name: String
|
||||
sentMessageCount: Int
|
||||
receivedMessageCount: Int
|
||||
deletedMessageCount: Int
|
||||
receivedCommandCount: Int
|
||||
movedUsersCount: Int
|
||||
|
||||
server: ID
|
||||
|
||||
deleted: Boolean
|
||||
dateFrom: String
|
||||
dateTo: String
|
||||
}
|
||||
|
||||
input ClientFilter {
|
||||
|
@ -1,7 +1,18 @@
|
||||
type KnownUser implements TableQuery {
|
||||
type KnownUser implements TableWithHistoryQuery {
|
||||
id: ID
|
||||
discordId: String
|
||||
|
||||
createdAt: String
|
||||
modifiedAt: String
|
||||
|
||||
history: [KnownUserHistory]
|
||||
}
|
||||
|
||||
type KnownUserHistory implements HistoryTableQuery {
|
||||
id: ID
|
||||
discordId: String
|
||||
|
||||
deleted: Boolean
|
||||
dateFrom: String
|
||||
dateTo: String
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
type Server implements TableQuery {
|
||||
type Server implements TableWithHistoryQuery {
|
||||
id: ID
|
||||
discordId: String
|
||||
name: String
|
||||
@ -18,6 +18,19 @@ type Server implements TableQuery {
|
||||
|
||||
createdAt: String
|
||||
modifiedAt: String
|
||||
|
||||
history: [HistoryTableQuery]
|
||||
}
|
||||
|
||||
type ServerHistory implements HistoryTableQuery {
|
||||
id: ID
|
||||
discordId: String
|
||||
name: String
|
||||
iconURL: String
|
||||
|
||||
deleted: Boolean
|
||||
dateFrom: String
|
||||
dateTo: String
|
||||
}
|
||||
|
||||
input ServerFilter {
|
||||
|
@ -1,4 +1,4 @@
|
||||
type User implements TableQuery {
|
||||
type User implements TableWithHistoryQuery {
|
||||
id: ID
|
||||
discordId: String
|
||||
name: String
|
||||
@ -20,6 +20,21 @@ type User implements TableQuery {
|
||||
|
||||
createdAt: String
|
||||
modifiedAt: String
|
||||
|
||||
history: [UserHistory]
|
||||
}
|
||||
|
||||
type UserHistory implements HistoryTableQuery {
|
||||
id: ID
|
||||
discordId: String
|
||||
xp: Int
|
||||
|
||||
server: ID
|
||||
leftServer: Boolean
|
||||
|
||||
deleted: Boolean
|
||||
dateFrom: String
|
||||
dateTo: String
|
||||
}
|
||||
|
||||
input UserFilter {
|
||||
|
@ -1,4 +1,4 @@
|
||||
type UserJoinedGameServer implements TableQuery {
|
||||
type UserJoinedGameServer implements TableWithHistoryQuery {
|
||||
id: ID
|
||||
gameServer: String
|
||||
user: User
|
||||
@ -8,6 +8,21 @@ type UserJoinedGameServer implements TableQuery {
|
||||
|
||||
createdAt: String
|
||||
modifiedAt: String
|
||||
|
||||
history: [UserJoinedGameServerHistory]
|
||||
}
|
||||
|
||||
type UserJoinedGameServerHistory implements HistoryTableQuery {
|
||||
id: ID
|
||||
gameServer: String
|
||||
user: ID
|
||||
time: Float
|
||||
joinedOn: String
|
||||
leavedOn: String
|
||||
|
||||
deleted: Boolean
|
||||
dateFrom: String
|
||||
dateTo: String
|
||||
}
|
||||
|
||||
input UserJoinedGameServerFilter {
|
||||
|
@ -1,4 +1,4 @@
|
||||
type UserJoinedServer implements TableQuery {
|
||||
type UserJoinedServer implements TableWithHistoryQuery {
|
||||
id: ID
|
||||
user: User
|
||||
joinedOn: String
|
||||
@ -6,6 +6,19 @@ type UserJoinedServer implements TableQuery {
|
||||
|
||||
createdAt: String
|
||||
modifiedAt: String
|
||||
|
||||
history: [UserJoinedServerHistory]
|
||||
}
|
||||
|
||||
type UserJoinedServerHistory implements HistoryTableQuery {
|
||||
id: ID
|
||||
user: ID
|
||||
joinedOn: String
|
||||
leavedOn: String
|
||||
|
||||
deleted: Boolean
|
||||
dateFrom: String
|
||||
dateTo: String
|
||||
}
|
||||
|
||||
input UserJoinedServerFilter {
|
||||
|
@ -1,4 +1,4 @@
|
||||
type UserJoinedVoiceChannel implements TableQuery {
|
||||
type UserJoinedVoiceChannel implements TableWithHistoryQuery {
|
||||
id: ID
|
||||
channelId: String
|
||||
channelName: String
|
||||
@ -9,6 +9,22 @@ type UserJoinedVoiceChannel implements TableQuery {
|
||||
|
||||
createdAt: String
|
||||
modifiedAt: String
|
||||
|
||||
history: [UserJoinedVoiceChannelHistory]
|
||||
}
|
||||
|
||||
type UserJoinedVoiceChannelHistory implements HistoryTableQuery {
|
||||
id: ID
|
||||
channelId: String
|
||||
channelName: String
|
||||
user: ID
|
||||
time: Float
|
||||
joinedOn: String
|
||||
leavedOn: String
|
||||
|
||||
deleted: Boolean
|
||||
dateFrom: String
|
||||
dateTo: String
|
||||
}
|
||||
|
||||
input UserJoinedVoiceChannelFilter {
|
||||
|
49
kdb-bot/src/bot_graphql/queries/auto_role_history_query.py
Normal file
49
kdb-bot/src/bot_graphql/queries/auto_role_history_query.py
Normal file
@ -0,0 +1,49 @@
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.model.auto_role import AutoRole
|
||||
from bot_graphql.abc.history_query_abc import HistoryQueryABC
|
||||
from bot_graphql.filter.server_filter import ServerFilter
|
||||
|
||||
|
||||
class AutoRoleHistoryQuery(HistoryQueryABC):
|
||||
def __init__(
|
||||
self,
|
||||
bot: DiscordBotServiceABC,
|
||||
auto_role_rules: AutoRoleRepositoryABC,
|
||||
servers: ServerRepositoryABC,
|
||||
):
|
||||
HistoryQueryABC.__init__(self, "AutoRole")
|
||||
|
||||
self._bot = bot
|
||||
self._auto_role_rules = auto_role_rules
|
||||
self._servers = servers
|
||||
|
||||
self.set_field("id", self.resolve_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)
|
||||
|
||||
@staticmethod
|
||||
def resolve_id(x: AutoRole, *_):
|
||||
return x.id
|
||||
|
||||
@staticmethod
|
||||
def resolve_channel_id(x: AutoRole, *_):
|
||||
return x.discord_channel_id
|
||||
|
||||
@staticmethod
|
||||
def resolve_channel_name(x: AutoRole, *_):
|
||||
return x.discord_channel_name
|
||||
|
||||
@staticmethod
|
||||
def resolve_message_id(x: AutoRole, *_):
|
||||
return x.discord_message_id
|
||||
|
||||
def resolve_server(self, x: AutoRole, *_, filter: ServerFilter = None):
|
||||
if filter is not None:
|
||||
return filter.filter(self._servers.get_server_by_id(x.server.id))
|
||||
|
||||
return self._servers.get_server_by_id(x.server.id)
|
@ -1,21 +1,24 @@
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.model.auto_role import AutoRole
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
from bot_data.model.auto_role_history import AutoRoleHistory
|
||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
||||
from bot_graphql.filter.auto_role_filter import AutoRoleFilter
|
||||
from bot_graphql.filter.server_filter import ServerFilter
|
||||
|
||||
|
||||
class AutoRoleQuery(DataQueryABC):
|
||||
class AutoRoleQuery(DataQueryWithHistoryABC):
|
||||
def __init__(
|
||||
self,
|
||||
bot: DiscordBotServiceABC,
|
||||
auto_role_rules: AutoRoleRepositoryABC,
|
||||
servers: ServerRepositoryABC,
|
||||
db: DatabaseContextABC,
|
||||
):
|
||||
DataQueryABC.__init__(self, "AutoRole")
|
||||
DataQueryWithHistoryABC.__init__(self, "AutoRole", "AutoRolesHistory", AutoRoleHistory, db)
|
||||
|
||||
self._bot = bot
|
||||
self._auto_role_rules = auto_role_rules
|
||||
|
@ -0,0 +1,42 @@
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
|
||||
from bot_data.model.auto_role_rule import AutoRoleRule
|
||||
from bot_graphql.abc.history_query_abc import HistoryQueryABC
|
||||
|
||||
|
||||
class AutoRoleRuleHistoryQuery(HistoryQueryABC):
|
||||
def __init__(
|
||||
self,
|
||||
bot: DiscordBotServiceABC,
|
||||
auto_roles: AutoRoleRepositoryABC,
|
||||
):
|
||||
HistoryQueryABC.__init__(self, "AutoRoleRule")
|
||||
|
||||
self._bot = bot
|
||||
self._auto_roles = auto_roles
|
||||
|
||||
self.set_field("id", self.resolve_id)
|
||||
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, *_):
|
||||
return x.id
|
||||
|
||||
@staticmethod
|
||||
def resolve_emoji_name(x: AutoRoleRule, *_):
|
||||
return x.emoji_name
|
||||
|
||||
@staticmethod
|
||||
def resolve_role_id(x: AutoRoleRule, *_):
|
||||
return x.role_id
|
||||
|
||||
@staticmethod
|
||||
def resolve_role_name(x: AutoRoleRule, *_):
|
||||
return x.role_name
|
||||
|
||||
def resolve_auto_role(self, x: AutoRoleRule, *_):
|
||||
return self._auto_roles.get_auto_role_by_id(x.auto_role.id)
|
@ -1,17 +1,15 @@
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
|
||||
from bot_data.model.auto_role_rule import AutoRoleRule
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
from bot_data.model.auto_role_rule_history import AutoRoleRuleHistory
|
||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
||||
|
||||
|
||||
class AutoRoleRuleQuery(DataQueryABC):
|
||||
def __init__(
|
||||
self,
|
||||
bot: DiscordBotServiceABC,
|
||||
auto_roles: AutoRoleRepositoryABC,
|
||||
):
|
||||
DataQueryABC.__init__(self, "AutoRoleRule")
|
||||
class AutoRoleRuleQuery(DataQueryWithHistoryABC):
|
||||
def __init__(self, bot: DiscordBotServiceABC, auto_roles: AutoRoleRepositoryABC, db: DatabaseContextABC):
|
||||
DataQueryWithHistoryABC.__init__(self, "AutoRoleRule", "AutoRoleRulesHistory", AutoRoleRuleHistory, db)
|
||||
|
||||
self._bot = bot
|
||||
self._auto_roles = auto_roles
|
||||
|
60
kdb-bot/src/bot_graphql/queries/client_history_query.py
Normal file
60
kdb-bot/src/bot_graphql/queries/client_history_query.py
Normal file
@ -0,0 +1,60 @@
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.model.client import Client
|
||||
from bot_graphql.abc.history_query_abc import HistoryQueryABC
|
||||
|
||||
|
||||
class ClientHistoryQuery(HistoryQueryABC):
|
||||
def __init__(
|
||||
self,
|
||||
bot: DiscordBotServiceABC,
|
||||
):
|
||||
HistoryQueryABC.__init__(self, "Client")
|
||||
|
||||
self._bot = bot
|
||||
|
||||
self.set_field("id", self.resolve_id)
|
||||
self.set_field("discordId", self.resolve_discord_id)
|
||||
self.set_field("name", self.resolve_name)
|
||||
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
|
||||
def resolve_id(client: Client, *_):
|
||||
return client.id
|
||||
|
||||
@staticmethod
|
||||
def resolve_discord_id(client: Client, *_):
|
||||
return client.discord_id
|
||||
|
||||
@staticmethod
|
||||
def resolve_name(client: Client, *_):
|
||||
return client.name
|
||||
|
||||
@staticmethod
|
||||
def resolve_sent_message_count(client: Client, *_):
|
||||
return client.sent_message_count
|
||||
|
||||
@staticmethod
|
||||
def resolve_received_message_count(client: Client, *_):
|
||||
return client.received_command_count
|
||||
|
||||
@staticmethod
|
||||
def resolve_deleted_message_count(client: Client, *_):
|
||||
return client.deleted_message_count
|
||||
|
||||
@staticmethod
|
||||
def resolve_received_command_count(client: Client, *_):
|
||||
return client.received_command_count
|
||||
|
||||
@staticmethod
|
||||
def resolve_moved_users_count(client: Client, *_):
|
||||
return client.moved_users_count
|
||||
|
||||
@staticmethod
|
||||
def resolve_server(client: Client, *_):
|
||||
return client.server
|
@ -1,15 +1,14 @@
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.model.client import Client
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
from bot_data.model.client_history import ClientHistory
|
||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
||||
|
||||
|
||||
class ClientQuery(DataQueryABC):
|
||||
def __init__(
|
||||
self,
|
||||
bot: DiscordBotServiceABC,
|
||||
):
|
||||
DataQueryABC.__init__(self, "Client")
|
||||
class ClientQuery(DataQueryWithHistoryABC):
|
||||
def __init__(self, bot: DiscordBotServiceABC, db: DatabaseContextABC):
|
||||
DataQueryWithHistoryABC.__init__(self, "Client", "ClientsHistory", ClientHistory, db)
|
||||
|
||||
self._bot = bot
|
||||
|
||||
|
18
kdb-bot/src/bot_graphql/queries/known_user_history_query.py
Normal file
18
kdb-bot/src/bot_graphql/queries/known_user_history_query.py
Normal file
@ -0,0 +1,18 @@
|
||||
from bot_data.model.known_user import KnownUser
|
||||
from bot_graphql.abc.history_query_abc import HistoryQueryABC
|
||||
|
||||
|
||||
class KnownUserHistoryQuery(HistoryQueryABC):
|
||||
def __init__(self):
|
||||
HistoryQueryABC.__init__(self, "KnownUser")
|
||||
|
||||
self.set_field("id", self.resolve_id)
|
||||
self.set_field("discordId", self.resolve_discord_id)
|
||||
|
||||
@staticmethod
|
||||
def resolve_id(x: KnownUser, *_):
|
||||
return x.id
|
||||
|
||||
@staticmethod
|
||||
def resolve_discord_id(x: KnownUser, *_):
|
||||
return x.discord_id
|
@ -1,10 +1,13 @@
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
|
||||
from bot_data.model.known_user import KnownUser
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
from bot_data.model.known_user_history import KnownUserHistory
|
||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
||||
|
||||
|
||||
class KnownUserQuery(DataQueryABC):
|
||||
def __init__(self):
|
||||
DataQueryABC.__init__(self, "KnownUser")
|
||||
class KnownUserQuery(DataQueryWithHistoryABC):
|
||||
def __init__(self, db: DatabaseContextABC):
|
||||
DataQueryWithHistoryABC.__init__(self, "KnownUser", "KnownUsersHistory", KnownUserHistory, db)
|
||||
|
||||
self.set_field("id", self.resolve_id)
|
||||
self.set_field("discordId", self.resolve_discord_id)
|
||||
|
@ -1,11 +1,10 @@
|
||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||
from bot_data.model.level import Level
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
from bot_graphql.abc.history_query_abc import HistoryQueryABC
|
||||
|
||||
|
||||
class LevelHistoryQuery(QueryABC):
|
||||
class LevelHistoryQuery(HistoryQueryABC):
|
||||
def __init__(self):
|
||||
QueryABC.__init__(self, "LevelHistory")
|
||||
HistoryQueryABC.__init__(self, "Level")
|
||||
|
||||
self.set_field("id", self.resolve_id)
|
||||
self.set_field("name", self.resolve_name)
|
||||
@ -13,9 +12,6 @@ class LevelHistoryQuery(QueryABC):
|
||||
self.set_field("minXp", self.resolve_min_xp)
|
||||
self.set_field("permissions", self.resolve_permissions)
|
||||
self.set_field("server", self.resolve_server)
|
||||
self.set_field("deleted", self.resolve_deleted)
|
||||
self.set_field("dateFrom", self.resolve_date_from)
|
||||
self.set_field("dateTo", self.resolve_date_to)
|
||||
|
||||
@staticmethod
|
||||
def resolve_id(level: Level, *_):
|
||||
@ -40,15 +36,3 @@ class LevelHistoryQuery(QueryABC):
|
||||
@staticmethod
|
||||
def resolve_server(level: Level, *_):
|
||||
return level.server
|
||||
|
||||
@staticmethod
|
||||
def resolve_deleted(entry: HistoryTableABC, *_):
|
||||
return entry.deleted
|
||||
|
||||
@staticmethod
|
||||
def resolve_date_from(entry: HistoryTableABC, *_):
|
||||
return entry.date_from
|
||||
|
||||
@staticmethod
|
||||
def resolve_date_to(entry: HistoryTableABC, *_):
|
||||
return entry.date_to
|
||||
|
30
kdb-bot/src/bot_graphql/queries/server_history_query.py
Normal file
30
kdb-bot/src/bot_graphql/queries/server_history_query.py
Normal file
@ -0,0 +1,30 @@
|
||||
from bot_data.model.server import Server
|
||||
from bot_graphql.abc.history_query_abc import HistoryQueryABC
|
||||
|
||||
|
||||
class ServerHistoryQuery(HistoryQueryABC):
|
||||
def __init__(
|
||||
self,
|
||||
):
|
||||
HistoryQueryABC.__init__(self, "Server")
|
||||
|
||||
self.set_field("id", self.resolve_id)
|
||||
self.set_field("discordId", self.resolve_discord_id)
|
||||
self.set_field("name", self.resolve_name)
|
||||
self.set_field("iconURL", self.resolve_icon_url)
|
||||
|
||||
@staticmethod
|
||||
def resolve_id(server: Server, *_):
|
||||
return server.id
|
||||
|
||||
@staticmethod
|
||||
def resolve_discord_id(server: Server, *_):
|
||||
return server.discord_id
|
||||
|
||||
@staticmethod
|
||||
def resolve_name(server: Server, *_):
|
||||
return server.name
|
||||
|
||||
@staticmethod
|
||||
def resolve_icon_url(server: Server, *_):
|
||||
return server.icon_url
|
@ -1,3 +1,4 @@
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.abc.auto_role_repository_abc import AutoRoleRepositoryABC
|
||||
@ -7,17 +8,20 @@ from bot_data.abc.user_joined_server_repository_abc import UserJoinedServerRepos
|
||||
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_data.model.server_history import ServerHistory
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
||||
from bot_graphql.filter.auto_role_filter import AutoRoleFilter
|
||||
from bot_graphql.filter.client_filter import ClientFilter
|
||||
from bot_graphql.filter.level_filter import LevelFilter
|
||||
from bot_graphql.filter.user_filter import UserFilter
|
||||
|
||||
|
||||
class ServerQuery(DataQueryABC):
|
||||
class ServerQuery(DataQueryWithHistoryABC):
|
||||
def __init__(
|
||||
self,
|
||||
bot: DiscordBotServiceABC,
|
||||
db: DatabaseContextABC,
|
||||
auto_roles: AutoRoleRepositoryABC,
|
||||
clients: ClientRepositoryABC,
|
||||
levels: LevelRepositoryABC,
|
||||
@ -25,7 +29,7 @@ class ServerQuery(DataQueryABC):
|
||||
ujs: UserJoinedServerRepositoryABC,
|
||||
ujvs: UserJoinedVoiceChannelRepositoryABC,
|
||||
):
|
||||
DataQueryABC.__init__(self, "Server")
|
||||
DataQueryWithHistoryABC.__init__(self, "Server", "ServersHistory", ServerHistory, db)
|
||||
|
||||
self._bot = bot
|
||||
self._auto_roles = auto_roles
|
||||
|
33
kdb-bot/src/bot_graphql/queries/user_history_query.py
Normal file
33
kdb-bot/src/bot_graphql/queries/user_history_query.py
Normal file
@ -0,0 +1,33 @@
|
||||
from bot_data.model.user import User
|
||||
from bot_graphql.abc.history_query_abc import HistoryQueryABC
|
||||
|
||||
|
||||
class UserHistoryQuery(HistoryQueryABC):
|
||||
def __init__(self):
|
||||
HistoryQueryABC.__init__(self, "User")
|
||||
|
||||
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("server", self.resolve_server)
|
||||
self.set_field("leftServer", self.resolve_left_server)
|
||||
|
||||
@staticmethod
|
||||
def resolve_id(user: User, *_):
|
||||
return user.id
|
||||
|
||||
@staticmethod
|
||||
def resolve_discord_id(user: User, *_):
|
||||
return user.discord_id
|
||||
|
||||
@staticmethod
|
||||
def resolve_xp(user: User, *_):
|
||||
return user.xp
|
||||
|
||||
@staticmethod
|
||||
def resolve_server(user: User, *_):
|
||||
return user.server
|
||||
|
||||
@staticmethod
|
||||
def resolve_left_server(user: User, *_):
|
||||
return user.left_server
|
@ -0,0 +1,41 @@
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.model.user_joined_game_server import UserJoinedGameServer
|
||||
from bot_graphql.abc.history_query_abc import HistoryQueryABC
|
||||
|
||||
|
||||
class UserJoinedGameServerHistoryQuery(HistoryQueryABC):
|
||||
def __init__(self, bot: DiscordBotServiceABC):
|
||||
HistoryQueryABC.__init__(self, "UserJoinedGameServer")
|
||||
|
||||
self._bot = bot
|
||||
|
||||
self.set_field("id", self.resolve_id)
|
||||
self.set_field("gameServer", self.resolve_game_server)
|
||||
self.set_field("user", self.resolve_user)
|
||||
self.set_field("joinedOn", self.resolve_joined_on)
|
||||
self.set_field("leavedOn", self.resolve_leaved_on)
|
||||
|
||||
@staticmethod
|
||||
def resolve_id(x: UserJoinedGameServer, *_):
|
||||
return x.id
|
||||
|
||||
@staticmethod
|
||||
def resolve_game_server(x: UserJoinedGameServer, *_):
|
||||
return x.game_server.name
|
||||
|
||||
@staticmethod
|
||||
def resolve_user(x: UserJoinedGameServer, *_):
|
||||
return x.user
|
||||
|
||||
@staticmethod
|
||||
def resolve_time(x: UserJoinedGameServer, *_):
|
||||
return x.time
|
||||
|
||||
@staticmethod
|
||||
def resolve_joined_on(x: UserJoinedGameServer, *_):
|
||||
return x.joined_on
|
||||
|
||||
@staticmethod
|
||||
def resolve_leaved_on(x: UserJoinedGameServer, *_):
|
||||
return x.leaved_on
|
@ -1,12 +1,16 @@
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.model.user_joined_game_server import UserJoinedGameServer
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
from bot_data.model.user_joined_game_server_history import UserJoinedGameServerHistory
|
||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
||||
|
||||
|
||||
class UserJoinedGameServerQuery(DataQueryABC):
|
||||
def __init__(self, bot: DiscordBotServiceABC):
|
||||
DataQueryABC.__init__(self, "UserJoinedGameServer")
|
||||
class UserJoinedGameServerQuery(DataQueryWithHistoryABC):
|
||||
def __init__(self, bot: DiscordBotServiceABC, db: DatabaseContextABC):
|
||||
DataQueryWithHistoryABC.__init__(
|
||||
self, "UserJoinedGameServer", "UserJoinedGameServersHistory", UserJoinedGameServerHistory, db
|
||||
)
|
||||
|
||||
self._bot = bot
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
from bot_data.model.user_joined_server import UserJoinedServer
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
|
||||
|
||||
class UserJoinedServerHistoryQuery(DataQueryABC):
|
||||
def __init__(self):
|
||||
DataQueryABC.__init__(self, "UserJoinedServer")
|
||||
|
||||
self.set_field("id", self.resolve_id)
|
||||
self.set_field("user", self.resolve_user)
|
||||
self.set_field("joinedOn", self.resolve_joined_on)
|
||||
self.set_field("leavedOn", self.resolve_leaved_on)
|
||||
|
||||
@staticmethod
|
||||
def resolve_id(x: UserJoinedServer, *_):
|
||||
return x.id
|
||||
|
||||
@staticmethod
|
||||
def resolve_user(x: UserJoinedServer, *_):
|
||||
return x.user
|
||||
|
||||
@staticmethod
|
||||
def resolve_joined_on(x: UserJoinedServer, *_):
|
||||
return x.joined_on
|
||||
|
||||
@staticmethod
|
||||
def resolve_leaved_on(x: UserJoinedServer, *_):
|
||||
return x.leaved_on
|
@ -1,10 +1,15 @@
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
|
||||
from bot_data.model.user_joined_server import UserJoinedServer
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
from bot_data.model.user_joined_server_history import UserJoinedServerHistory
|
||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
||||
|
||||
|
||||
class UserJoinedServerQuery(DataQueryABC):
|
||||
def __init__(self):
|
||||
DataQueryABC.__init__(self, "UserJoinedServer")
|
||||
class UserJoinedServerQuery(DataQueryWithHistoryABC):
|
||||
def __init__(self, db: DatabaseContextABC):
|
||||
DataQueryWithHistoryABC.__init__(
|
||||
self, "UserJoinedServer", "UserJoinedServersHistory", UserJoinedServerHistory, db
|
||||
)
|
||||
|
||||
self.set_field("id", self.resolve_id)
|
||||
self.set_field("user", self.resolve_user)
|
||||
|
@ -0,0 +1,47 @@
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
|
||||
from bot_graphql.abc.history_query_abc import HistoryQueryABC
|
||||
|
||||
|
||||
class UserJoinedVoiceChannelHistoryQuery(HistoryQueryABC):
|
||||
def __init__(self, bot: DiscordBotServiceABC):
|
||||
HistoryQueryABC.__init__(self, "UserJoinedVoiceChannel")
|
||||
|
||||
self._bot = bot
|
||||
|
||||
self.set_field("id", self.resolve_id)
|
||||
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("time", self.resolve_time)
|
||||
self.set_field("joinedOn", self.resolve_joined_on)
|
||||
self.set_field("leavedOn", self.resolve_leaved_on)
|
||||
|
||||
@staticmethod
|
||||
def resolve_id(x: UserJoinedVoiceChannel, *_):
|
||||
return x.id
|
||||
|
||||
@staticmethod
|
||||
def resolve_channel_id(x: UserJoinedVoiceChannel, *_):
|
||||
return x.channel_id
|
||||
|
||||
@staticmethod
|
||||
def resolve_channel_name(x: UserJoinedVoiceChannel, *_):
|
||||
return x.channel_name
|
||||
|
||||
@staticmethod
|
||||
def resolve_user(x: UserJoinedVoiceChannel, *_):
|
||||
return x.user
|
||||
|
||||
@staticmethod
|
||||
def resolve_time(x: UserJoinedVoiceChannel, *_):
|
||||
return x.time
|
||||
|
||||
@staticmethod
|
||||
def resolve_joined_on(x: UserJoinedVoiceChannel, *_):
|
||||
return x.joined_on
|
||||
|
||||
@staticmethod
|
||||
def resolve_leaved_on(x: UserJoinedVoiceChannel, *_):
|
||||
return x.leaved_on
|
@ -1,12 +1,16 @@
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
|
||||
from bot_graphql.abc.data_query_abc import DataQueryABC
|
||||
from bot_data.model.user_joined_voice_channel_history import UserJoinedVoiceChannelHistory
|
||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
||||
|
||||
|
||||
class UserJoinedVoiceChannelQuery(DataQueryABC):
|
||||
def __init__(self, bot: DiscordBotServiceABC):
|
||||
DataQueryABC.__init__(self, "UserJoinedVoiceChannel")
|
||||
class UserJoinedVoiceChannelQuery(DataQueryWithHistoryABC):
|
||||
def __init__(self, bot: DiscordBotServiceABC, db: DatabaseContextABC):
|
||||
DataQueryWithHistoryABC.__init__(
|
||||
self, "UserJoinedVoiceChannel", "UserJoinedVoiceChannelsHistory", UserJoinedVoiceChannelHistory, db
|
||||
)
|
||||
|
||||
self._bot = bot
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
@ -5,7 +6,8 @@ from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameSe
|
||||
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_graphql.abc.data_query_abc import DataQueryABC
|
||||
from bot_data.model.user_history import UserHistory
|
||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
||||
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
|
||||
@ -13,10 +15,11 @@ from modules.level.service.level_service import LevelService
|
||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||
|
||||
|
||||
class UserQuery(DataQueryABC):
|
||||
class UserQuery(DataQueryWithHistoryABC):
|
||||
def __init__(
|
||||
self,
|
||||
bot: DiscordBotServiceABC,
|
||||
db: DatabaseContextABC,
|
||||
levels: LevelService,
|
||||
client_utils: ClientUtilsABC,
|
||||
ujs: UserJoinedServerRepositoryABC,
|
||||
@ -24,7 +27,7 @@ class UserQuery(DataQueryABC):
|
||||
user_joined_game_server: UserJoinedGameServerRepositoryABC,
|
||||
permissions: PermissionServiceABC,
|
||||
):
|
||||
DataQueryABC.__init__(self, "User")
|
||||
DataQueryWithHistoryABC.__init__(self, "User", "UsersHistory", UserHistory, db)
|
||||
|
||||
self._bot = bot
|
||||
self._levels = levels
|
||||
|
Loading…
Reference in New Issue
Block a user