mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
Allow excluding test key use in the all services stats query
This commit is contained in:
@@ -239,8 +239,8 @@ def dao_fetch_weekly_historical_stats_for_service(service_id):
|
|||||||
|
|
||||||
|
|
||||||
@statsd(namespace='dao')
|
@statsd(namespace='dao')
|
||||||
def dao_fetch_todays_stats_for_all_services():
|
def dao_fetch_todays_stats_for_all_services(include_from_test_key=True):
|
||||||
return db.session.query(
|
query = db.session.query(
|
||||||
Notification.notification_type,
|
Notification.notification_type,
|
||||||
Notification.status,
|
Notification.status,
|
||||||
Notification.service_id,
|
Notification.service_id,
|
||||||
@@ -258,3 +258,8 @@ def dao_fetch_todays_stats_for_all_services():
|
|||||||
).order_by(
|
).order_by(
|
||||||
Notification.service_id
|
Notification.service_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not include_from_test_key:
|
||||||
|
query = query.filter(Notification.key_type != KEY_TYPE_TEST)
|
||||||
|
|
||||||
|
return query
|
||||||
|
|||||||
@@ -628,3 +628,14 @@ def test_dao_fetch_todays_stats_for_all_services_includes_all_keys_by_default(no
|
|||||||
|
|
||||||
assert len(stats) == 1
|
assert len(stats) == 1
|
||||||
assert stats[0].count == 3
|
assert stats[0].count == 3
|
||||||
|
|
||||||
|
|
||||||
|
def test_dao_fetch_todays_stats_for_all_services_can_exclude_from_test_key(notify_db, notify_db_session):
|
||||||
|
create_notification(notify_db, notify_db_session, key_type=KEY_TYPE_NORMAL)
|
||||||
|
create_notification(notify_db, notify_db_session, key_type=KEY_TYPE_TEAM)
|
||||||
|
create_notification(notify_db, notify_db_session, key_type=KEY_TYPE_TEST)
|
||||||
|
|
||||||
|
stats = dao_fetch_todays_stats_for_all_services(include_from_test_key=False).all()
|
||||||
|
|
||||||
|
assert len(stats) == 1
|
||||||
|
assert stats[0].count == 2
|
||||||
|
|||||||
Reference in New Issue
Block a user