mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 18:31:13 -05:00
refactor template stats endpoint to read from new redis keys
New redis keys are partitioned per service per day. New process is as follows: * require a count of days to filter by. Currently admin always gives 7. * for each day, check and see if there's anything in redis. There won't be if either a) redis is/was down or b) the service didn't send any notifications that day - if there isn't, go to the database and get a count out. * combine all these stats together * get the names/template types etc out of the DB at the end.
This commit is contained in:
@@ -50,7 +50,7 @@ from app.utils import convert_utc_to_bst, get_london_midnight_in_utc
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def dao_get_template_usage(service_id, limit_days=None, day=None):
|
||||
def dao_get_template_usage(service_id, *, limit_days=None, day=None):
|
||||
if bool(limit_days) == bool(day):
|
||||
raise ValueError('Must filter on either limit_days or a specific day')
|
||||
|
||||
@@ -75,8 +75,9 @@ def dao_get_template_usage(service_id, limit_days=None, day=None):
|
||||
).group_by(
|
||||
Notification.template_id
|
||||
).subquery()
|
||||
|
||||
query = db.session.query(
|
||||
Template.id.label('template_id'),
|
||||
Template.id,
|
||||
Template.name,
|
||||
Template.template_type,
|
||||
Template.is_precompiled_letter,
|
||||
|
||||
Reference in New Issue
Block a user