mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Merge pull request #2305 from alphagov/fix-template-usage-query
Add missing filter for template usage query
This commit is contained in:
@@ -312,7 +312,8 @@ def fetch_monthly_template_usage_for_service(start_date, end_date, service_id):
|
|||||||
FactNotificationStatus.service_id == service_id,
|
FactNotificationStatus.service_id == service_id,
|
||||||
FactNotificationStatus.bst_date >= start_date,
|
FactNotificationStatus.bst_date >= start_date,
|
||||||
FactNotificationStatus.bst_date <= end_date,
|
FactNotificationStatus.bst_date <= end_date,
|
||||||
FactNotificationStatus.notification_status != NOTIFICATION_CANCELLED
|
FactNotificationStatus.key_type != KEY_TYPE_TEST,
|
||||||
|
FactNotificationStatus.notification_status != NOTIFICATION_CANCELLED,
|
||||||
).group_by(
|
).group_by(
|
||||||
FactNotificationStatus.template_id,
|
FactNotificationStatus.template_id,
|
||||||
Template.name,
|
Template.name,
|
||||||
|
|||||||
@@ -461,3 +461,24 @@ def test_fetch_monthly_template_usage_for_service_does_not_include_cancelled_sta
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert len(results) == 0
|
assert len(results) == 0
|
||||||
|
|
||||||
|
|
||||||
|
@freeze_time('2018-03-30 14:00')
|
||||||
|
def test_fetch_monthly_template_usage_for_service_does_not_include_test_notifications(
|
||||||
|
sample_template
|
||||||
|
):
|
||||||
|
create_ft_notification_status(bst_date=date(2018, 3, 1),
|
||||||
|
service=sample_template.service,
|
||||||
|
template=sample_template,
|
||||||
|
notification_status='delivered',
|
||||||
|
key_type='test',
|
||||||
|
count=15)
|
||||||
|
create_notification(template=sample_template,
|
||||||
|
created_at=datetime.utcnow(),
|
||||||
|
status='delivered',
|
||||||
|
key_type='test',)
|
||||||
|
results = fetch_monthly_template_usage_for_service(
|
||||||
|
datetime(2018, 1, 1), datetime(2018, 3, 31), sample_template.service_id
|
||||||
|
)
|
||||||
|
|
||||||
|
assert len(results) == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user