diff --git a/app/models/packages.py b/app/models/packages.py index 88776ad5..43874262 100644 --- a/app/models/packages.py +++ b/app/models/packages.py @@ -590,10 +590,10 @@ class Package(db.Model): "video_url": self.video_url, "donate_url": self.donate_url_actual, - "tags": [x.name for x in self.tags], - "content_warnings": [x.name for x in self.content_warnings], + "tags": sorted([x.name for x in self.tags]), + "content_warnings": sorted([x.name for x in self.content_warnings]), - "provides": [x.name for x in self.provides], + "provides": sorted([x.name for x in self.provides]), "thumbnail": (base_url + tnurl) if tnurl is not None else None, "screenshots": [base_url + ss.url for ss in self.screenshots], diff --git a/app/utils/__init__.py b/app/utils/__init__.py index eb7df470..bf018f24 100644 --- a/app/utils/__init__.py +++ b/app/utils/__init__.py @@ -20,6 +20,8 @@ from typing import Dict import typing +import deep_compare + from .flask import * from .models import * from .user import * @@ -73,7 +75,7 @@ def has_blocked_domains(text: str, username: str, location: str) -> bool: return False -def diff_dictionaries(one: Dict, two: Dict): +def diff_dictionaries(one: Dict, two: Dict) -> List: if len(set(one.keys()).difference(set(two.keys()))) != 0: raise "Mismatching keys" @@ -82,14 +84,14 @@ def diff_dictionaries(one: Dict, two: Dict): for key, before in one.items(): after = two[key] - if before is dict: + if isinstance(before, dict): diff = diff_dictionaries(before, after) if len(diff) != 0: retval.append({ "key": key, "changes": diff, }) - elif before != after: + elif not deep_compare.CompareVariables.compare(before, after): retval.append({ "key": key, "before": before, diff --git a/requirements.lock.txt b/requirements.lock.txt index 4913e09d..643cecc1 100644 --- a/requirements.lock.txt +++ b/requirements.lock.txt @@ -16,6 +16,7 @@ click-plugins==1.1.1 click-repl==0.2.0 coverage==7.2.3 decorator==5.1.1 +deep-compare==1.0.5 dnspython==2.3.0 email-validator==2.0.0.post1 exceptiongroup==1.1.1 diff --git a/requirements.txt b/requirements.txt index 6949e49d..23cd581a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -46,3 +46,5 @@ alembic validators gitdb + +deep-compare