Add option to exclude test key stats on platform admin page

This page currently includes all notifications for all services, including
those sent using a test key. Stats on all other pages exclude test key usage,
though, which can lead to confusion for admins comparing numbers between
pages. Adding the option to toggle between including and excluding test key
usage on the platform admin page gives context for this difference, and allows
admins to see live usage of the platform as well as load associated with test
key usage.
This commit is contained in:
Jenny Duckett
2016-12-05 12:23:29 +00:00
parent fc2ea8aeb8
commit c88a961e04
3 changed files with 85 additions and 26 deletions

View File

@@ -1,6 +1,9 @@
import itertools
from flask import render_template
from flask import (
render_template,
request
)
from flask_login import login_required
from app import service_api_client
@@ -13,10 +16,15 @@ from app.statistics_utils import get_formatted_percentage
@login_required
@user_has_permissions(admin_override=True)
def platform_admin():
include_from_test_key = request.args.get('include_from_test_key') != 'False'
# specifically DO get inactive services
services = service_api_client.get_services({'detailed': True})['data']
api_args = {'detailed': True}
if not include_from_test_key:
api_args['include_from_test_key'] = False
services = service_api_client.get_services(api_args)['data']
return render_template(
'views/platform-admin.html',
include_from_test_key=include_from_test_key,
**get_statistics(sorted(
services,
key=lambda service: (service['active'], service['created_at']),