Skip to content

Commit

Permalink
account info storing - bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecot committed Jul 30, 2024
1 parent 7513519 commit 09014ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lavapProviderHealth/dbworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions lavapProviderHealth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 09014ec

Please sign in to comment.