mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-05 23:08:25 -04:00
Improve display of failure rates
https://www.pivotaltracker.com/story/show/116052359 - add absolute numbers for failures - make percentages accurate to 1 decimal place (50.0%) - make error colour appear if failures go above 3.0% - make error colour boolean (don’t interpolate between the colours)
This commit is contained in:
@@ -25,21 +25,13 @@
|
|||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%big-number-status,
|
||||||
.big-number-status {
|
.big-number-status {
|
||||||
|
|
||||||
|
@include core-19;
|
||||||
display: block;
|
display: block;
|
||||||
background: $green;
|
background: $green;
|
||||||
position: relative;
|
padding: 15px;
|
||||||
|
|
||||||
&-error-percentage {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background: $error-colour;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
|
|
||||||
@@ -52,16 +44,11 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.big-number {
|
}
|
||||||
@include bold-19;
|
|
||||||
position: relative;
|
|
||||||
z-index: 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.big-number-label {
|
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
.big-number-status-failing {
|
||||||
|
@extend %big-number-status;
|
||||||
|
background: $error-colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ def service_dashboard(service_id):
|
|||||||
free_text_messages_remaining='250,000',
|
free_text_messages_remaining='250,000',
|
||||||
spent_this_month='0.00',
|
spent_this_month='0.00',
|
||||||
service=service['data'],
|
service=service['data'],
|
||||||
statistics=expand_statistics(statistics),
|
statistics=add_rates_to(statistics),
|
||||||
templates=templates,
|
templates=templates,
|
||||||
service_id=str(service_id))
|
service_id=str(service_id))
|
||||||
|
|
||||||
@@ -51,28 +51,27 @@ def service_dashboard_updates(service_id):
|
|||||||
return jsonify(**{
|
return jsonify(**{
|
||||||
'today': render_template(
|
'today': render_template(
|
||||||
'views/dashboard/today.html',
|
'views/dashboard/today.html',
|
||||||
statistics=expand_statistics(statistics),
|
statistics=add_rates_to(statistics),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def expand_statistics(statistics, danger_zone=25):
|
def add_rates_to(delivery_statistics):
|
||||||
|
|
||||||
if not statistics or not statistics[0]:
|
if not delivery_statistics or not delivery_statistics[0]:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
today = statistics[0]
|
today = delivery_statistics[0]
|
||||||
|
|
||||||
today.update({
|
today.update({
|
||||||
'emails_failure_rate':
|
'emails_failure_rate': (
|
||||||
int(today['emails_error'] / today['emails_requested'] * 100) if today['emails_requested'] else 0,
|
"{0:.1f}".format((today['emails_error'] / today['emails_requested'] * 100))
|
||||||
'sms_failure_rate':
|
if today['emails_requested'] else 0
|
||||||
int(today['sms_error'] / today['sms_requested'] * 100) if today['sms_requested'] else 0
|
),
|
||||||
})
|
'sms_failure_rate': (
|
||||||
|
"{0:.1f}".format((today['sms_error'] / today['sms_requested'] * 100))
|
||||||
today.update({
|
if today['sms_requested'] else 0
|
||||||
'emails_percentage_of_danger_zone': min(today['emails_failure_rate'] / (danger_zone / 100), 100),
|
)
|
||||||
'sms_percentage_of_danger_zone': min(today['sms_failure_rate'] / (danger_zone / 100), 100)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return today
|
return today
|
||||||
|
|||||||
@@ -6,12 +6,15 @@
|
|||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
{% macro big_number_with_status(number, label, status_number, status_label, percentage_bad=0) %}
|
{% macro big_number_with_status(number, label, failures, failure_percentage, danger_zone=False) %}
|
||||||
<div class="big-number-with-status">
|
<div class="big-number-with-status">
|
||||||
{{ big_number(number, label) }}
|
{{ big_number(number, label) }}
|
||||||
<div class="big-number-status">
|
<div class="big-number-status{% if danger_zone %}-failing{% endif %}">
|
||||||
<div class="big-number-status-error-percentage" style="opacity: {{ percentage_bad / 100 }}"></div>
|
{% if failures %}
|
||||||
{{ big_number(status_number, status_label) }}
|
{{ failures }} failed – {{ failure_percentage }}%
|
||||||
|
{% else %}
|
||||||
|
No failures
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|||||||
@@ -8,18 +8,18 @@
|
|||||||
{{ big_number_with_status(
|
{{ big_number_with_status(
|
||||||
statistics.get('emails_requested', 0),
|
statistics.get('emails_requested', 0),
|
||||||
'email' if statistics.get('emails_requested') == 1 else 'emails',
|
'email' if statistics.get('emails_requested') == 1 else 'emails',
|
||||||
'{}%'.format(statistics.get('emails_failure_rate', 0)),
|
statistics.get('emails_error'),
|
||||||
'failed',
|
statistics.get('emails_failure_rate', 0.0),
|
||||||
statistics.get('emails_percentage_of_danger_zone', 0)
|
statistics.get('emails_failure_rate', 0)|float > 3
|
||||||
) }}
|
) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="column-half">
|
<div class="column-half">
|
||||||
{{ big_number_with_status(
|
{{ big_number_with_status(
|
||||||
statistics.get('sms_requested', 0),
|
statistics.get('sms_requested', 0),
|
||||||
'text message' if statistics.get('sms_requested') == 1 else 'text messages',
|
'text message' if statistics.get('sms_requested') == 1 else 'text messages',
|
||||||
'{}%'.format(statistics.get('sms_failure_rate', 0)),
|
statistics.get('sms_error'),
|
||||||
'failed',
|
statistics.get('sms_failure_rate', 0.0),
|
||||||
statistics.get('sms_percentage_of_danger_zone', 0)
|
statistics.get('sms_failure_rate', 0)|float > 3
|
||||||
) }}
|
) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user