Merge pull request #471 from alphagov/craig-david

Show the last 7 days of statistics on the dashboard
This commit is contained in:
Chris Hill-Scott
2016-04-20 11:13:51 +01:00
7 changed files with 66 additions and 50 deletions

View File

@@ -6,12 +6,18 @@
{% endmacro %}
{% macro big_number_with_status(number, label, failures, failure_percentage, danger_zone=False) %}
{% macro big_number_with_status(number, label, failures, failure_percentage, danger_zone=False, failure_link=None) %}
<div class="big-number-with-status">
{{ big_number(number, label) }}
<div class="big-number-status{% if danger_zone %}-failing{% endif %}">
{% if failures %}
{{ failures }} failed {{ failure_percentage }}%
{% if failure_link %}
<a href="{{ failure_link }}">
{{ failures }} failed {{ failure_percentage }}%
</a>
{% else %}
{{ failures }} failed {{ failure_percentage }}%
{% endif %}
{% else %}
No failures
{% endif %}

View File

@@ -1,9 +1,10 @@
{% from "components/table.html" import list_table, field, hidden_field_heading, right_aligned_field_heading %}
{% call(item, row_number) list_table(
template_statistics,
caption="In the last 7 days",
caption="By template",
caption_visible=False,
empty_message='You havent set up any templates yet',
field_headings=['Template', hidden_field_heading('Type'), right_aligned_field_heading('Messages sent')]
field_headings=['Template', hidden_field_heading('Type'), right_aligned_field_heading('Messages processed')]
) %}
{% call field() %}
<a href="{{ url_for('.view_template', service_id=current_service.id, template_id=item.template.id) }}">

View File

@@ -1,16 +1,17 @@
{% from "components/big-number.html" import big_number_with_status %}
<h2 class="heading-medium">
Sent today
In the last 7 days
</h2>
<div class="grid-row">
<div class="grid-row bottom-gutter">
<div class="column-half">
{{ big_number_with_status(
statistics.get('emails_requested', 0),
'email' if statistics.get('emails_requested') == 1 else 'emails',
statistics.get('emails_delivered', 0),
'email' if statistics.get('emails_delivered') == 1 else 'emails',
statistics.get('emails_failed'),
statistics.get('emails_failure_rate', 0.0),
statistics.get('emails_failure_rate', 0)|float > 3
statistics.get('emails_failure_rate', 0)|float > 3,
failure_link=url_for(".view_notifications", service_id=current_service.id, template_type='email', status='failed')
) }}
</div>
<div class="column-half">
@@ -19,10 +20,10 @@
'text message' if statistics.get('sms_requested') == 1 else 'text messages',
statistics.get('sms_failed'),
statistics.get('sms_failure_rate', 0.0),
statistics.get('sms_failure_rate', 0)|float > 3
statistics.get('sms_failure_rate', 0)|float > 3,
failure_link=url_for(".view_notifications", service_id=current_service.id, template_type='sms', status='failed')
) }}
</div>
</div>
{% include 'views/dashboard/template-statistics.html' %}