Skip to content

Commit

Permalink
Refactor condition checks in Database class to simplify method compar…
Browse files Browse the repository at this point in the history
…isons
  • Loading branch information
TheophileDiot committed Jan 27, 2025
1 parent bf47c1d commit 48d59ea
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/common/db/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1462,9 +1462,7 @@ def process_service(server_name: str, service_config: Dict[str, str], db_ids: Di
local_to_update.append(
{"model": Services, "filter": {"id": server_name}, "values": {"last_update": datetime.now().astimezone()}}
)
elif (
method in (service_setting["method"], "autoconf") or (method == "scheduler" and service_setting["method"] != "autoconf")
) and service_setting["value"] != value:
elif method in (service_setting["method"], "autoconf") and service_setting["value"] != value:
local_changed_plugins.add(setting["plugin_id"])

if key != "SERVER_NAME" and (
Expand Down Expand Up @@ -1534,9 +1532,7 @@ def process_global_settings(global_config: Dict[str, str]):
self.logger.debug(f"Adding global setting {key}")
local_changed_plugins.add(setting["plugin_id"])
local_to_put.append(Global_values(setting_id=key, value=value, suffix=suffix, method=method))
elif (
method in (global_value.method, "autoconf") or (method == "scheduler" and global_value.method != "autoconf")
) and global_value.value != value:
elif method in (global_value.method, "autoconf") and global_value.value != value:
local_changed_plugins.add(setting["plugin_id"])

if (
Expand Down Expand Up @@ -1636,9 +1632,7 @@ def process_global_settings(global_config: Dict[str, str]):
self.logger.debug(f"Adding global setting {key}")
changed_plugins.add(setting.plugin_id)
to_put.append(Global_values(setting_id=key, value=value, suffix=suffix, method=method))
elif (
method in (global_value.method, "autoconf") or (method == "scheduler" and global_value.method != "autoconf")
) and global_value.value != value:
elif method in (global_value.method, "autoconf") and global_value.value != value:
changed_plugins.add(setting.plugin_id)

if value == (template_setting.default if template_setting is not None else setting.default):
Expand Down Expand Up @@ -1762,9 +1756,7 @@ def save_custom_configs(

if not custom_conf:
to_put.append(Custom_configs(**custom_config))
elif custom_config["checksum"] != custom_conf.checksum and (
method in (custom_conf.method, "autoconf") or (method == "scheduler" and custom_conf.method != "autoconf")
):
elif custom_config["checksum"] != custom_conf.checksum and method in (custom_conf.method, "autoconf"):
custom_conf.data = custom_config["data"]
custom_conf.checksum = custom_config["checksum"]
custom_conf.method = method
Expand Down

0 comments on commit 48d59ea

Please sign in to comment.