Sort platform admin page by requested messages.

- puts services that are doing things at the top.
This commit is contained in:
Martyn Inglis
2017-04-25 12:54:58 +01:00
parent d88199e414
commit 146772f22e
2 changed files with 98 additions and 2 deletions

View File

@@ -35,12 +35,19 @@ def platform_admin():
form=form,
**get_statistics(sorted(
services,
key=lambda service: (service['active'], service['created_at']),
key=lambda service: (service['active'], sum_service_usage(service), service['created_at']),
reverse=True
))
)
def sum_service_usage(service):
total = 0
for notification_type in service['statistics'].keys():
total += service['statistics'][notification_type]['requested']
return total
def get_statistics(services):
return {
'global_stats': create_global_stats(services),