Skip to content

Commit

Permalink
[#1946] Refactor condition checks in Database class to avoid default …
Browse files Browse the repository at this point in the history
…value check when a multiple has a suffix
  • Loading branch information
TheophileDiot committed Jan 27, 2025
1 parent 3bf3e70 commit 120cff2
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/common/db/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1445,9 +1445,12 @@ def process_service(server_name: str, service_config: Dict[str, str], db_ids: Di
value == template_setting_default
if template_setting_default is not None
else (
value == setting["default"]
if original_key not in config and original_key not in db_config
else value in (config.get(original_key), db_config.get(original_key))
not suffix
and (
value == setting["default"]
if original_key not in config and original_key not in db_config
else value in (config.get(original_key), db_config.get(original_key))
)
)
):
continue
Expand All @@ -1468,9 +1471,12 @@ def process_service(server_name: str, service_config: Dict[str, str], db_ids: Di
value == template_setting_default
if template_setting_default is not None
else (
value == setting["default"]
if original_key not in config and original_key not in db_config
else value in (config.get(original_key), db_config.get(original_key))
not suffix
and (
value == setting["default"]
if original_key not in config and original_key not in db_config
else value in (config.get(original_key), db_config.get(original_key))
)
)
):
self.logger.debug(f"Removing setting {key} for service {server_name}")
Expand Down Expand Up @@ -1521,7 +1527,7 @@ def process_global_settings(global_config: Dict[str, str]):
if (
template_setting_default is not None
and value == template_setting_default
or (template_setting_default is None and value == setting["default"])
or (not suffix and template_setting_default is None and value == setting["default"])
):
continue

Expand All @@ -1536,7 +1542,7 @@ def process_global_settings(global_config: Dict[str, str]):
if (
template_setting_default is not None
and value == template_setting_default
or (template_setting_default is None and value == setting["default"])
or (not suffix and template_setting_default is None and value == setting["default"])
):
self.logger.debug(f"Removing global setting {key}")
local_to_delete.append({"model": Global_values, "filter": {"setting_id": key, "suffix": suffix}})
Expand Down

0 comments on commit 120cff2

Please sign in to comment.