Changed config loading from file to db #127
This commit is contained in:
@@ -2,6 +2,7 @@ import hashlib
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
@@ -15,19 +16,18 @@ from bot_data.abc.user_game_ident_repository_abc import UserGameIdentRepositoryA
|
||||
from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC
|
||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||
from bot_data.model.api_key import ApiKey
|
||||
from bot_data.model.server_config import ServerConfig
|
||||
from bot_data.model.user_joined_game_server import UserJoinedGameServer
|
||||
from bot_data.model.user_role_enum import UserRoleEnum
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
from modules.base.abc.base_helper_abc import BaseHelperABC
|
||||
from modules.base.configuration.base_server_settings import BaseServerSettings
|
||||
from modules.permission.service.permission_service import PermissionService
|
||||
|
||||
|
||||
class UserJoinedGameServerMutation(QueryABC):
|
||||
def __init__(
|
||||
self,
|
||||
config: ConfigurationABC,
|
||||
logger: LoggerABC,
|
||||
base_helper: BaseHelperABC,
|
||||
servers: ServerRepositoryABC,
|
||||
users: UserRepositoryABC,
|
||||
user_joined_game_servers: UserJoinedGameServerRepositoryABC,
|
||||
@@ -41,8 +41,8 @@ class UserJoinedGameServerMutation(QueryABC):
|
||||
):
|
||||
QueryABC.__init__(self, "UserJoinedGameServerMutation")
|
||||
|
||||
self._config = config
|
||||
self._logger = logger
|
||||
self._base_helper = base_helper
|
||||
self._servers = servers
|
||||
self._users = users
|
||||
self._user_joined_game_servers = user_joined_game_servers
|
||||
@@ -116,7 +116,7 @@ class UserJoinedGameServerMutation(QueryABC):
|
||||
return
|
||||
active.leaved_on = datetime.now()
|
||||
|
||||
settings: BaseServerSettings = self._base_helper.get_config(user.server.discord_id)
|
||||
settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{user.server.discord_id}")
|
||||
|
||||
ontime = round((active.leaved_on - active.joined_on).total_seconds() / 3600, 2)
|
||||
old_xp = user.xp
|
||||
|
Reference in New Issue
Block a user