Fix incorrect difference detected due to order of tags

This commit is contained in:
rubenwardy 2023-05-12 00:45:27 +01:00
parent 9738a8a826
commit 84d379d490
4 changed files with 11 additions and 6 deletions

@ -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],

@ -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,

@ -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

@ -46,3 +46,5 @@ alembic
validators
gitdb
deep-compare