Sort services by newest created first

Other than which services are live it’s also interesting to know what
services are getting created on Notify. So let’s put the newest ones at
the top of the page.
This commit is contained in:
Chris Hill-Scott
2016-09-12 11:40:21 +01:00
parent 88fff50ea3
commit 311ae4cfa4
3 changed files with 11 additions and 4 deletions

View File

@@ -18,7 +18,11 @@ def platform_admin():
services = service_api_client.get_services({'detailed': True})['data']
return render_template(
'views/platform-admin.html',
**get_statistics(services)
**get_statistics(sorted(
services,
key=lambda service: service['created_at'],
reverse=True
))
)
@@ -67,5 +71,6 @@ def format_stats_by_service(services):
'delivered': sum(stat['delivered'] for stat in stats),
'failed': sum(stat['failed'] for stat in stats),
'restricted': service['restricted'],
'research_mode': service['research_mode']
'research_mode': service['research_mode'],
'created_at': service['created_at']
}

View File

@@ -65,7 +65,8 @@ def service_json(
'sms_sender': sms_sender,
'research_mode': research_mode,
'organisation': organisation,
'branding': branding
'branding': branding,
'created_at': str(datetime.utcnow())
}

View File

@@ -84,7 +84,8 @@ def mock_get_detailed_service(mocker, api_user_active):
'statistics': {
'email': {'requested': 0, 'delivered': 0, 'failed': 0},
'sms': {'requested': 0, 'delivered': 0, 'failed': 0}
}
},
'created_at': str(datetime.utcnow())
}
}