sort rest response by org_name, service_name

needed to re-arrange test results for this
This commit is contained in:
Leo Hemsted
2019-08-29 15:45:50 +01:00
parent 7811010e6c
commit b46eed1423
2 changed files with 19 additions and 13 deletions

View File

@@ -100,4 +100,9 @@ def get_usage_for_all_services():
for service_id, breakdown in lb_by_service:
combined[service_id]['letter_breakdown'] += (breakdown + '\n')
return jsonify(list(combined.values()))
# sorting first by name == '' means that blank orgs will be sorted last.
return jsonify(sorted(combined.values(), key=lambda x: (
x['organisation_name'] == '',
x['organisation_name'],
x['service_name']
)))