Sort the modal data

This commit is contained in:
Mark Veidemanis 2022-07-21 13:51:43 +01:00
parent b5ff784a0e
commit eb039af9f2
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 7 additions and 0 deletions

View File

@ -23,6 +23,12 @@ def escape(obj):
return obj return obj
def sort_data(data):
for item in data:
if isinstance(data[item], list):
data[item].sort()
def threshold_request(url, data): def threshold_request(url, data):
headers = { headers = {
"ApiKey": settings.THRESHOLD_API_KEY, "ApiKey": settings.THRESHOLD_API_KEY,
@ -46,6 +52,7 @@ def threshold_request(url, data):
response = r.json() response = r.json()
except JSONDecodeError: except JSONDecodeError:
logging.error(f"Invalid JSON response: {r.text}") logging.error(f"Invalid JSON response: {r.text}")
sort_data(response)
return response return response