Add limit_days argument to notification statistics endpoint

Allows getting notification counts for a given number of days to
support services with custom data retention periods (admin dashboard
page should still display counts for the last 7 days, while the
notifications page displays all stored notifications).
This commit is contained in:
Alexey Bezhan
2018-08-13 16:34:04 +01:00
parent 3e51b69df6
commit 5f2724c429
3 changed files with 18 additions and 11 deletions

View File

@@ -246,9 +246,9 @@ def delete_service_and_all_associated_db_objects(service):
@statsd(namespace="dao")
def dao_fetch_stats_for_service(service_id):
def dao_fetch_stats_for_service(service_id, limit_days):
# We always want between seven and eight days
start_date = midnight_n_days_ago(7)
start_date = midnight_n_days_ago(limit_days)
return _stats_for_service_query(service_id).filter(
Notification.created_at >= start_date
).all()