diff --git a/lavapProviderHealth/dbworker.py b/lavapProviderHealth/dbworker.py index 374e623..63a98ed 100644 --- a/lavapProviderHealth/dbworker.py +++ b/lavapProviderHealth/dbworker.py @@ -113,7 +113,7 @@ def db_worker_work_accountinfo(data): result = db_cur_fetchone() if result is not None: - existing_data = result[0]["data"] + existing_data = result[0] new_data = data['data'] if replace_for_compare(existing_data) != replace_for_compare(new_data): # If data is different, insert a new record diff --git a/lavapProviderHealth/utils.py b/lavapProviderHealth/utils.py index 1b396f7..40705ac 100644 --- a/lavapProviderHealth/utils.py +++ b/lavapProviderHealth/utils.py @@ -151,6 +151,14 @@ def is_health_status_better(old_status: str, new_status: str, old_data: str, new return False def replace_for_compare(data): + # Convert data types to a uniform format before comparison + if isinstance(data, (dict, list)): + data = json.dumps(data, sort_keys=True) + elif data is None: + data = 'null' + elif data == 0: + data = '0' + return str(data).replace(" ", "").replace("\t", "").replace("\n", "").lower() def convert_dict_to_dbjson(data):