mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 22:42:28 -05:00
make sure redis command filters dates properly
also write the tests that i should have written a while ago for this
This commit is contained in:
@@ -504,7 +504,12 @@ def populate_redis_template_usage(service_id, day):
|
||||
Recalculate and replace the stats in redis for a day.
|
||||
To be used if redis data is lost for some reason.
|
||||
"""
|
||||
# the day variable is set to midnight of that day
|
||||
assert current_app.config['REDIS_ENABLED']
|
||||
|
||||
start_time = get_london_midnight_in_utc(day)
|
||||
end_time = get_london_midnight_in_utc(day + timedelta(days=1))
|
||||
|
||||
usage = {
|
||||
str(row.template_id): row.count
|
||||
for row in db.session.query(
|
||||
@@ -512,6 +517,8 @@ def populate_redis_template_usage(service_id, day):
|
||||
func.count().label('count')
|
||||
).filter(
|
||||
Notification.service_id == service_id,
|
||||
Notification.created_at >= start_time,
|
||||
Notification.created_at < end_time
|
||||
).group_by(
|
||||
Notification.template_id
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user