1.0.0 #253

Merged
edraft merged 262 commits from 1.0.0 into master 2023-03-27 09:30:50 +02:00
Showing only changes of commit 22d26bf032 - Show all commits

View File

@ -1,24 +1,30 @@
from cpl_core.database.context import DatabaseContextABC
from cpl_discord.service import DiscordBotServiceABC
from bot_data.abc.level_repository_abc import LevelRepositoryABC
from bot_data.abc.server_repository_abc import ServerRepositoryABC
from bot_data.model.level import Level
from bot_data.model.user_role_enum import UserRoleEnum
from bot_graphql.abc.query_abc import QueryABC
from modules.level.level_seeder import LevelSeeder
class LevelMutation(QueryABC):
def __init__(
self,
bot: DiscordBotServiceABC,
servers: ServerRepositoryABC,
levels: LevelRepositoryABC,
db: DatabaseContextABC,
level_seeder: LevelSeeder,
):
QueryABC.__init__(self, "LevelMutation")
self._bot = bot
self._servers = servers
self._levels = levels
self._db = db
self._level_seeder = level_seeder
self.set_field("createLevel", self.resolve_create_level)
self.set_field("updateLevel", self.resolve_update_level)
@ -46,6 +52,7 @@ class LevelMutation(QueryABC):
and l.permissions == level.permissions
)
self._bot.loop.create_task(self._level_seeder.seed())
return self._levels.get_levels_by_server_id(level.server.id).where(get_new_level).last()
def resolve_update_level(self, *_, input: dict):
@ -60,6 +67,7 @@ class LevelMutation(QueryABC):
self._levels.update_level(level)
self._db.save_changes()
self._bot.loop.create_task(self._level_seeder.seed())
level = self._levels.get_level_by_id(input["id"])
return level
@ -69,4 +77,6 @@ class LevelMutation(QueryABC):
self._levels.delete_level(level)
self._db.save_changes()
self._bot.loop.create_task(self._level_seeder.seed())
return level