mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
Exclude test key notifications from:
- get all notifications by service - template usage - most recently used templates Ensures that the dashboard shows no test key data. Supplements: https://github.com/alphagov/notifications-api/pull/677 which excludes CSV data. This branches from that so is dependant.
This commit is contained in:
@@ -21,7 +21,7 @@ from app.models import (
|
||||
NOTIFICATION_CREATED,
|
||||
NOTIFICATION_SENDING,
|
||||
NOTIFICATION_PENDING,
|
||||
NOTIFICATION_TEMPORARY_FAILURE, KEY_TYPE_NORMAL)
|
||||
NOTIFICATION_TEMPORARY_FAILURE, KEY_TYPE_NORMAL, KEY_TYPE_TEST)
|
||||
|
||||
from app.dao.dao_utils import transactional
|
||||
from app.statsd_decorators import statsd
|
||||
@@ -97,7 +97,7 @@ def dao_get_template_usage(service_id, limit_days=None):
|
||||
Template.template_type
|
||||
)
|
||||
|
||||
query_filter = [table.service_id == service_id]
|
||||
query_filter = [table.service_id == service_id, table.key_type != KEY_TYPE_TEST]
|
||||
if limit_days is not None:
|
||||
query_filter.append(table.created_at >= days_ago(limit_days))
|
||||
|
||||
@@ -110,7 +110,9 @@ def dao_get_template_usage(service_id, limit_days=None):
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def dao_get_last_template_usage(template_id):
|
||||
return NotificationHistory.query.filter(NotificationHistory.template_id == template_id) \
|
||||
return NotificationHistory.query.filter(
|
||||
NotificationHistory.template_id == template_id,
|
||||
NotificationHistory.key_type != KEY_TYPE_TEST) \
|
||||
.join(Template) \
|
||||
.order_by(desc(NotificationHistory.created_at)) \
|
||||
.first()
|
||||
@@ -248,6 +250,9 @@ def get_notifications_for_service(service_id,
|
||||
|
||||
if key_type is not None:
|
||||
filters.append(Notification.key_type == key_type)
|
||||
else:
|
||||
filters.append(Notification.key_type != KEY_TYPE_TEST)
|
||||
|
||||
query = Notification.query.filter(*filters)
|
||||
query = _filter_query(query, filter_dict)
|
||||
if personalisation:
|
||||
|
||||
Reference in New Issue
Block a user