mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-17 21:20:59 -04:00
Merge pull request #679 from alphagov/remove-test-keys-from-admin-app
Remove test keys from admin app
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:
|
||||
|
||||
@@ -23,8 +23,8 @@ from app.models import (
|
||||
Permission,
|
||||
User,
|
||||
InvitedUser,
|
||||
Service
|
||||
)
|
||||
Service,
|
||||
KEY_TYPE_TEST)
|
||||
from app.statsd_decorators import statsd
|
||||
|
||||
|
||||
@@ -156,7 +156,8 @@ def _stats_for_service_query(service_id):
|
||||
Notification.status,
|
||||
func.count(Notification.id).label('count')
|
||||
).filter(
|
||||
Notification.service_id == service_id
|
||||
Notification.service_id == service_id,
|
||||
Notification.key_type != KEY_TYPE_TEST
|
||||
).group_by(
|
||||
Notification.notification_type,
|
||||
Notification.status,
|
||||
|
||||
Reference in New Issue
Block a user