mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
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:
@@ -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']),
|
||||
|
||||
@@ -95,31 +95,45 @@
|
||||
},
|
||||
]) }}
|
||||
|
||||
<div class="grid-row">
|
||||
<div class="column-one-third">
|
||||
<nav class="navigation">
|
||||
<ul>
|
||||
{% if include_from_test_key %}
|
||||
<li>Including test key (<a href="{{ url_for('.platform_admin', include_from_test_key=False) }}">change</a>)</li>
|
||||
{% else %}
|
||||
<li>Excluding test key (<a href="{{ url_for('.platform_admin') }}">change</a>)</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<main role="main" class="column-two-thirds column-main">
|
||||
<h2 class='heading-medium'>Today</h2>
|
||||
<div class="grid-row bottom-gutter">
|
||||
<div class="column-half">
|
||||
{{ big_number_with_status(
|
||||
global_stats.email.delivered,
|
||||
message_count_label(global_stats.email.delivered, 'email'),
|
||||
global_stats.email.failed,
|
||||
global_stats.email.failure_rate,
|
||||
global_stats.email.failure_rate|float > 3,
|
||||
) }}
|
||||
</div>
|
||||
<div class="column-half">
|
||||
{{ big_number_with_status(
|
||||
global_stats.sms.delivered,
|
||||
message_count_label(global_stats.sms.delivered, 'sms'),
|
||||
global_stats.sms.failed,
|
||||
global_stats.sms.failure_rate,
|
||||
global_stats.sms.failure_rate|float > 3,
|
||||
) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class='heading-medium'>Today</h2>
|
||||
<div class="grid-row bottom-gutter">
|
||||
<div class="column-half">
|
||||
{{ big_number_with_status(
|
||||
global_stats.email.delivered,
|
||||
message_count_label(global_stats.email.delivered, 'email'),
|
||||
global_stats.email.failed,
|
||||
global_stats.email.failure_rate,
|
||||
global_stats.email.failure_rate|float > 3,
|
||||
) }}
|
||||
</div>
|
||||
<div class="column-half">
|
||||
{{ big_number_with_status(
|
||||
global_stats.sms.delivered,
|
||||
message_count_label(global_stats.sms.delivered, 'sms'),
|
||||
global_stats.sms.failed,
|
||||
global_stats.sms.failure_rate,
|
||||
global_stats.sms.failure_rate|float > 3,
|
||||
) }}
|
||||
</div>
|
||||
{{ services_table(live_services, 'Live services') }}
|
||||
|
||||
{{ services_table(trial_mode_services, 'Trial mode services') }}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
{{ services_table(live_services, 'Live services') }}
|
||||
|
||||
{{ services_table(trial_mode_services, 'Trial mode services') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user