Put usage summary back on the dashboard

This reverts 1b1839ad30, which removed
the usage from the dashboard because it was causing performance
problems:

> **The yearly usage section on the dashboard page takes too log as a
> result services with large yearly stats are timing out.**
>
> As a short term fix we have taken the yearly stats off the dashboard.
>
> There is a plan to create permanent statistic tables to warehouse the
> data.

The long term fix (the fact tables) is now in place, so it should be OK
to bring this back.

This is part of a wider piece of work to refresh the dashboard page now
that jobs are moving to their own page.
This commit is contained in:
Chris Hill-Scott
2019-10-25 13:27:46 +01:00
parent 8782049548
commit 889d601475
6 changed files with 91 additions and 6 deletions

View File

@@ -299,7 +299,14 @@ def get_dashboard_partials(service_id):
)
for key, value in dashboard_totals[0].items()
)
free_sms_allowance = billing_api_client.get_free_sms_fragment_limit_for_year(
current_service.id,
get_current_financial_year(),
)
yearly_usage = billing_api_client.get_service_usage(
service_id,
get_current_financial_year(),
)
return {
'upcoming': render_template(
'views/dashboard/_upcoming.html',
@@ -332,7 +339,12 @@ def get_dashboard_partials(service_id):
'views/dashboard/_jobs.html',
jobs=immediate_jobs
),
'has_jobs': bool(immediate_jobs)
'has_jobs': bool(immediate_jobs),
'usage': render_template(
'views/dashboard/_usage.html',
column_width=column_width,
**calculate_usage(yearly_usage, free_sms_allowance),
),
}