#127_config_in_wi #327
@ -1 +1 @@
|
||||
Subproject commit 4264ba15970a28f8a50c888bbf635a15c438bcf9
|
||||
Subproject commit 359f9c38c3ec825a89f3bf289a65ec035cfcb693
|
@ -1 +1 @@
|
||||
Subproject commit c712f856ebe30c71ac0b144045599ed2f91a1cba
|
||||
Subproject commit 6d3f253f4121191308b4b0d5f01fa1c61b61406a
|
@ -74,6 +74,6 @@ class TechnicianIdConfig(TableABC):
|
||||
return str(
|
||||
f"""
|
||||
DELETE FROM `CFG_TechnicianIds`
|
||||
WHERE `Id` = {self._id};
|
||||
WHERE `TechnicianId` = {self._technician_id};
|
||||
"""
|
||||
)
|
||||
|
@ -74,6 +74,6 @@ class TechnicianPingUrlConfig(TableABC):
|
||||
return str(
|
||||
f"""
|
||||
DELETE FROM `CFG_TechnicianPingUrls`
|
||||
WHERE `Id` = {self._id};
|
||||
WHERE `URL` = {self._ping_url};
|
||||
"""
|
||||
)
|
||||
|
@ -24,6 +24,7 @@ from bot_graphql.mutations.achievement_mutation import AchievementMutation
|
||||
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.technician_config_mutation import TechnicianConfigMutation
|
||||
from bot_graphql.mutations.user_joined_game_server_mutation import UserJoinedGameServerMutation
|
||||
from bot_graphql.mutations.user_mutation import UserMutation
|
||||
from bot_graphql.queries.achievement_attribute_query import AchievementAttributeQuery
|
||||
@ -120,5 +121,6 @@ class GraphQLModule(ModuleABC):
|
||||
services.add_transient(QueryABC, UserMutation)
|
||||
services.add_transient(QueryABC, AchievementMutation)
|
||||
services.add_transient(QueryABC, UserJoinedGameServerMutation)
|
||||
services.add_transient(QueryABC, TechnicianConfigMutation)
|
||||
|
||||
services.add_transient(SeederService)
|
||||
|
@ -5,4 +5,5 @@ type Mutation {
|
||||
user: UserMutation
|
||||
userJoinedGameServer: UserJoinedGameServerMutation
|
||||
achievement: AchievementMutation
|
||||
technicianConfig: TechnicianConfigMutation
|
||||
}
|
@ -46,9 +46,7 @@ type TechnicianIdConfigHistory implements HistoryTableQuery {
|
||||
}
|
||||
|
||||
type TechnicianConfigMutation {
|
||||
createTechnicianConfig(input: TechnicianConfigInput!): TechnicianConfig
|
||||
updateTechnicianConfig(input: TechnicianConfigInput!): TechnicianConfig
|
||||
deleteTechnicianConfig(id: ID): TechnicianConfig
|
||||
}
|
||||
|
||||
input TechnicianConfigInput {
|
@ -4,6 +4,7 @@ from bot_graphql.mutations.achievement_mutation import AchievementMutation
|
||||
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.technician_config_mutation import TechnicianConfigMutation
|
||||
from bot_graphql.mutations.user_joined_game_server_mutation import UserJoinedGameServerMutation
|
||||
from bot_graphql.mutations.user_mutation import UserMutation
|
||||
|
||||
@ -17,6 +18,7 @@ class Mutation(MutationType):
|
||||
user_mutation: UserMutation,
|
||||
achievement_mutation: AchievementMutation,
|
||||
user_joined_game_server: UserJoinedGameServerMutation,
|
||||
technician_config: TechnicianConfigMutation,
|
||||
):
|
||||
MutationType.__init__(self)
|
||||
|
||||
@ -26,3 +28,4 @@ class Mutation(MutationType):
|
||||
self.set_field("user", lambda *_: user_mutation)
|
||||
self.set_field("achievement", lambda *_: achievement_mutation)
|
||||
self.set_field("userJoinedGameServer", lambda *_: user_joined_game_server)
|
||||
self.set_field("technicianConfig", lambda *_: technician_config)
|
||||
|
@ -4,6 +4,8 @@ from cpl_discord.service import DiscordBotServiceABC
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.abc.technician_config_repository_abc import TechnicianConfigRepositoryABC
|
||||
from bot_data.model.technician_config import TechnicianConfig
|
||||
from bot_data.model.technician_id_config import TechnicianIdConfig
|
||||
from bot_data.model.technician_ping_url_config import TechnicianPingUrlConfig
|
||||
from bot_data.model.user_role_enum import UserRoleEnum
|
||||
from bot_graphql.abc.query_abc import QueryABC
|
||||
|
||||
@ -23,44 +25,65 @@ class TechnicianConfigMutation(QueryABC):
|
||||
self._technician_configs = technician_configs
|
||||
self._db = db
|
||||
|
||||
self.set_field("createTechnicianConfig", self.resolve_create_TechnicianConfig)
|
||||
self.set_field("updateTechnicianConfig", self.resolve_update_TechnicianConfig)
|
||||
self.set_field("deleteTechnicianConfig", self.resolve_delete_TechnicianConfig)
|
||||
|
||||
def resolve_create_technician_config(self, *_, input: dict):
|
||||
if self._technician_configs.does_technician_config_exists():
|
||||
return None
|
||||
|
||||
technician_config = TechnicianConfig(
|
||||
input["helpCommandReferenceUrl"],
|
||||
input["waitForRestart"],
|
||||
input["waitForShutdown"],
|
||||
input["cacheMaxMessages"],
|
||||
input["pingURLs"],
|
||||
input["technicianIds"],
|
||||
)
|
||||
self._technician_configs.add_technician_config(technician_config)
|
||||
self._db.save_changes()
|
||||
|
||||
return self._technician_configs.get_technician_config()
|
||||
self.set_field("updateTechnicianConfig", self.resolve_update_technician_config)
|
||||
|
||||
def resolve_update_technician_config(self, *_, input: dict):
|
||||
technician_config = self._technician_configs.get_technician_config()
|
||||
self._can_user_mutate_data(technician_config, UserRoleEnum.admin)
|
||||
|
||||
technician_config.name = input["name"] if "name" in input else technician_config.name
|
||||
technician_config.help_command_reference_url = (
|
||||
input["helpCommandReferenceUrl"]
|
||||
if "helpCommandReferenceUrl" in input
|
||||
else technician_config.help_command_reference_url
|
||||
)
|
||||
technician_config.wait_for_restart = (
|
||||
input["waitForRestart"] if "waitForRestart" in input else technician_config.wait_for_restart
|
||||
)
|
||||
technician_config.wait_for_shutdown = (
|
||||
input["waitForShutdown"] if "waitForShutdown" in input else technician_config.wait_for_shutdown
|
||||
)
|
||||
technician_config.cache_max_messages = (
|
||||
input["cacheMaxMessages"] if "cacheMaxMessages" in input else technician_config.cache_max_messages
|
||||
)
|
||||
technician_config.ping_urls = input["pingURLs"] if "pingURLs" in input else technician_config.ping_urls
|
||||
technician_config.technician_ids = (
|
||||
input["technicianIds"] if "technicianIds" in input else technician_config.technician_ids
|
||||
)
|
||||
|
||||
self._technician_configs.update_technician_config(technician_config)
|
||||
if "pingURLs" in input:
|
||||
self._update_ping_urls(technician_config)
|
||||
|
||||
if "technicianIds" in input:
|
||||
self._update_technician_ids(technician_config)
|
||||
|
||||
self._technician_configs.update_TechnicianConfig(technician_config)
|
||||
self._db.save_changes()
|
||||
|
||||
technician_config = self._technician_configs.get_TechnicianConfig_by_id(input["id"])
|
||||
return technician_config
|
||||
|
||||
def resolve_delete_technician_config(self, *_, id: int):
|
||||
technician_config = self._technician_configs.get_TechnicianConfig_by_id(id)
|
||||
self._can_user_mutate_data(technician_config.server, UserRoleEnum.admin)
|
||||
def _update_ping_urls(self, new_config: TechnicianConfig):
|
||||
old_config = self._technician_configs.get_technician_config()
|
||||
for url in old_config.ping_urls:
|
||||
if url in new_config.ping_urls:
|
||||
continue
|
||||
|
||||
self._technician_configs.delete_TechnicianConfig(technician_config)
|
||||
self._db.save_changes()
|
||||
self._technician_configs.delete_technician_ping_url_config(TechnicianPingUrlConfig(url))
|
||||
|
||||
return technician_config
|
||||
for url in new_config.ping_urls:
|
||||
if url in old_config.ping_urls:
|
||||
continue
|
||||
|
||||
self._technician_configs.add_technician_ping_url_config(TechnicianPingUrlConfig(url))
|
||||
|
||||
def _update_technician_ids(self, new_config: TechnicianConfig):
|
||||
old_config = self._technician_configs.get_technician_config()
|
||||
for url in old_config.technician_ids:
|
||||
if url in new_config.technician_ids:
|
||||
continue
|
||||
|
||||
self._technician_configs.delete_technician_id_config(TechnicianIdConfig(url))
|
||||
|
||||
for url in new_config.technician_ids:
|
||||
if url in old_config.technician_ids:
|
||||
continue
|
||||
|
||||
self._technician_configs.add_technician_id_config(TechnicianIdConfig(url))
|
||||
|
Loading…
Reference in New Issue
Block a user