mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-03 07:31:28 -04:00
use new detailed service endpoint for dashboard totals
we don't want to use the old statistics endpoints any more also a couple of quality of life changes * moves some logic out of the _totals.html template * tidies up statistics_utils
This commit is contained in:
@@ -31,18 +31,12 @@ def sum_of_statistics(delivery_statistics):
|
||||
def add_rates_to(delivery_statistics):
|
||||
|
||||
return dict(
|
||||
emails_failure_rate=(
|
||||
"{0:.1f}".format(
|
||||
float(delivery_statistics['emails_failed']) / delivery_statistics['emails_requested'] * 100
|
||||
)
|
||||
if delivery_statistics['emails_requested'] else 0
|
||||
),
|
||||
sms_failure_rate=(
|
||||
"{0:.1f}".format(
|
||||
float(delivery_statistics['sms_failed']) / delivery_statistics['sms_requested'] * 100
|
||||
)
|
||||
if delivery_statistics['sms_requested'] else 0
|
||||
),
|
||||
email_failure_rate=get_formatted_percentage(
|
||||
delivery_statistics['email_failed'],
|
||||
delivery_statistics['email_requested']),
|
||||
sms_failure_rate=get_formatted_percentage(
|
||||
delivery_statistics['sms_failed'],
|
||||
delivery_statistics['sms_requested']),
|
||||
week_end_datetime=parser.parse(
|
||||
delivery_statistics.get('week_end', str(datetime.utcnow()))
|
||||
),
|
||||
@@ -50,6 +44,13 @@ def add_rates_to(delivery_statistics):
|
||||
)
|
||||
|
||||
|
||||
def get_formatted_percentage(x, tot):
|
||||
"""
|
||||
Return a percentage to one decimal place (respecting )
|
||||
"""
|
||||
return "{0:.1f}".format((float(x) / tot * 100)) if tot else 0
|
||||
|
||||
|
||||
def statistics_by_state(statistics):
|
||||
return {
|
||||
'sms': {
|
||||
|
||||
Reference in New Issue
Block a user