Admin app now in line with new API response for template statistics

- dropped the day level aggregate. Now grouped by template only,
This commit is contained in:
Martyn Inglis
2016-08-22 13:14:35 +01:00
parent 4cab7ffb3c
commit 63fa77fde7
2 changed files with 69 additions and 116 deletions

View File

@@ -99,28 +99,11 @@ def weekly(service_id):
def aggregate_usage(template_statistics):
# grouby requires the list to be sorted by template first
statistics_sorted_by_template = sorted(
return sorted(
template_statistics,
key=lambda template_statistic: template_statistic['template_name']
)
totals = sorted(
(
{
'count': sum(usage['count'] for usage in usages),
'template_name': template_name,
'template_id': template_id,
'template_type': template_type
}
for (template_name, template_id, template_type), usages in groupby(statistics_sorted_by_template, lambda items: (items['template_name'], items['template_id'], items['template_type'])) # noqa
),
key=lambda row: row['count'],
reverse=True
)
return totals
def get_dashboard_partials(service_id):