mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
Tried to make this clearer
This commit is contained in:
@@ -103,12 +103,23 @@ def create_notification_statistics_dict(service_id, day):
|
|||||||
|
|
||||||
@statsd(namespace="dao")
|
@statsd(namespace="dao")
|
||||||
def dao_get_template_usage(service_id, limit_days=None):
|
def dao_get_template_usage(service_id, limit_days=None):
|
||||||
|
query_filter = []
|
||||||
|
|
||||||
table = NotificationHistory
|
table = NotificationHistory
|
||||||
|
|
||||||
if limit_days and limit_days <= 7: # can get this data from notifications table
|
if limit_days is not None and limit_days <= 7:
|
||||||
table = Notification
|
table = Notification
|
||||||
|
|
||||||
query_filter = [table.service_id == service_id, table.key_type != KEY_TYPE_TEST]
|
# only limit days if it's not seven days, as 7 days == the whole of Notifications table.
|
||||||
|
if limit_days != 7:
|
||||||
|
query_filter.append(table.created_at >= days_ago(limit_days))
|
||||||
|
|
||||||
|
elif limit_days is not None:
|
||||||
|
# case where not under 7 days, so using NotificationsHistory so limit allowed
|
||||||
|
query_filter.append(table.created_at >= days_ago(limit_days))
|
||||||
|
|
||||||
|
query_filter.append(table.service_id == service_id)
|
||||||
|
query_filter.append(table.key_type != KEY_TYPE_TEST)
|
||||||
|
|
||||||
# only limit days if it's not seven days, as 7 days == the whole of Notifications table.
|
# only limit days if it's not seven days, as 7 days == the whole of Notifications table.
|
||||||
if limit_days is not None and limit_days != 7:
|
if limit_days is not None and limit_days != 7:
|
||||||
|
|||||||
Reference in New Issue
Block a user