mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-09 00:43:12 -04:00
Add Template name to response and filter by year
The template name should be returned for the response and the user will pick a year, so ths adds those two features to the notifications/templates_usage/monthly endpoint and added some tests to test the functionality.
This commit is contained in:
@@ -30,11 +30,16 @@ def insert_or_update_stats_for_template(template_id, month, year, count):
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def dao_get_template_usage_stats_by_service(service_id):
|
||||
def dao_get_template_usage_stats_by_service(service_id, year):
|
||||
return db.session.query(
|
||||
StatsTemplateUsageByMonth
|
||||
StatsTemplateUsageByMonth.template_id,
|
||||
Template.name,
|
||||
StatsTemplateUsageByMonth.month,
|
||||
StatsTemplateUsageByMonth.year,
|
||||
StatsTemplateUsageByMonth.count
|
||||
).join(
|
||||
Template, StatsTemplateUsageByMonth.template_id == Template.id
|
||||
).filter(
|
||||
Template.service_id == service_id
|
||||
Template.service_id == service_id,
|
||||
StatsTemplateUsageByMonth.year == year
|
||||
).all()
|
||||
|
||||
Reference in New Issue
Block a user