mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
Added a template_type to the rest call
Added a template type which is required for the admin UI and updated the tests. The rest tests needed updated because of the bug fix for aggregation.
This commit is contained in:
@@ -243,7 +243,7 @@ class Config(object):
|
||||
'options': {'queue': QueueNames.PERIODIC}
|
||||
},
|
||||
'daily-stats-template-usage-by-month': {
|
||||
'task': 'daily-stats-template_usage_by_month',
|
||||
'task': 'daily-stats-template-usage-by-month',
|
||||
'schedule': crontab(hour=0, minute=50),
|
||||
'options': {'queue': QueueNames.PERIODIC}
|
||||
}
|
||||
|
||||
@@ -554,6 +554,7 @@ def dao_fetch_monthly_historical_usage_by_template_for_service(service_id, year)
|
||||
for result in results:
|
||||
stat = type("", (), {})()
|
||||
stat.template_id = result.template_id
|
||||
stat.template_type = result.template_type
|
||||
stat.name = str(result.name)
|
||||
stat.month = result.month
|
||||
stat.year = result.year
|
||||
@@ -567,6 +568,7 @@ def dao_fetch_monthly_historical_usage_by_template_for_service(service_id, year)
|
||||
today_results = db.session.query(
|
||||
Notification.template_id,
|
||||
Template.name,
|
||||
Template.template_type,
|
||||
extract('month', month).label('month'),
|
||||
extract('year', year).label('year'),
|
||||
func.count().label('count')
|
||||
@@ -577,6 +579,7 @@ def dao_fetch_monthly_historical_usage_by_template_for_service(service_id, year)
|
||||
).group_by(
|
||||
Notification.template_id,
|
||||
Template.name,
|
||||
Template.template_type,
|
||||
month,
|
||||
year
|
||||
).order_by(
|
||||
@@ -595,6 +598,7 @@ def dao_fetch_monthly_historical_usage_by_template_for_service(service_id, year)
|
||||
if add_to_stats:
|
||||
new_stat = type("", (), {})()
|
||||
new_stat.template_id = today_result.template_id
|
||||
new_stat.template_type = today_result.template_type
|
||||
new_stat.name = today_result.name
|
||||
new_stat.month = today_result.month
|
||||
new_stat.year = today_result.year
|
||||
|
||||
@@ -34,6 +34,7 @@ def dao_get_template_usage_stats_by_service(service_id, year):
|
||||
return db.session.query(
|
||||
StatsTemplateUsageByMonth.template_id,
|
||||
Template.name,
|
||||
Template.template_type,
|
||||
StatsTemplateUsageByMonth.month,
|
||||
StatsTemplateUsageByMonth.year,
|
||||
StatsTemplateUsageByMonth.count
|
||||
|
||||
@@ -539,6 +539,7 @@ def get_monthly_template_usage(service_id):
|
||||
{
|
||||
'template_id': str(i.template_id),
|
||||
'name': i.name,
|
||||
'type': i.template_type,
|
||||
'month': i.month,
|
||||
'year': i.year,
|
||||
'count': i.count
|
||||
|
||||
Reference in New Issue
Block a user