Start sending letters from insolvency service again

This commit is contained in:
Pea Tyczynska
2020-10-20 18:02:57 +01:00
parent c149f5020f
commit 9ac65ee95c
2 changed files with 2 additions and 34 deletions

View File

@@ -721,16 +721,12 @@ def dao_get_letters_to_be_printed(print_run_deadline, postage):
""" """
Return all letters created before the print run deadline that have not yet been sent Return all letters created before the print run deadline that have not yet been sent
""" """
notifications = Notification.query.join( notifications = Notification.query.filter(
Service,
Notification.service_id == Service.id
).filter(
Notification.created_at < convert_bst_to_utc(print_run_deadline), Notification.created_at < convert_bst_to_utc(print_run_deadline),
Notification.notification_type == LETTER_TYPE, Notification.notification_type == LETTER_TYPE,
Notification.status == NOTIFICATION_CREATED, Notification.status == NOTIFICATION_CREATED,
Notification.key_type == KEY_TYPE_NORMAL, Notification.key_type == KEY_TYPE_NORMAL,
Notification.postage == postage, Notification.postage == postage
or_(Service.organisation_id != 'f33fdfdd-7533-40cb-b5e8-cd78a1f5d21e', Service.organisation_id.is_(None)),
).order_by( ).order_by(
Notification.service_id, Notification.service_id,
Notification.created_at Notification.created_at

View File

@@ -49,7 +49,6 @@ from app.models import (
from tests.app.db import ( from tests.app.db import (
create_job, create_job,
create_notification, create_notification,
create_organisation,
create_service, create_service,
create_template, create_template,
create_notification_history create_notification_history
@@ -1696,30 +1695,3 @@ def test_letters_to_be_printed_sort_by_service(notify_db_session):
results = dao_get_letters_to_be_printed(print_run_deadline=datetime(2020, 12, 1, 17, 30), postage='second') results = dao_get_letters_to_be_printed(print_run_deadline=datetime(2020, 12, 1, 17, 30), postage='second')
assert len(results) == 3 assert len(results) == 3
assert results == [notification_1, notification_2, notification_3] assert results == [notification_1, notification_2, notification_3]
def test_dao_get_letters_to_be_printed_does_not_fetch_insolvency_org_letters(notify_db_session):
insolvency_org = create_organisation(organisation_id='f33fdfdd-7533-40cb-b5e8-cd78a1f5d21e', name="Insolvency")
other_org = create_organisation(name="Other Org")
insolvency_service = create_service(
service_name='insolvency_service',
organisation=insolvency_org
)
no_org_service = create_service(
service_name='no_org_service'
)
other_org_service = create_service(
service_name='other_org_service',
organisation=other_org
)
first_template = create_template(service=insolvency_service, template_type='letter', postage='second')
second_template = create_template(service=no_org_service, template_type='letter', postage='second')
third_template = create_template(service=other_org_service, template_type='letter', postage='second')
create_notification(template=first_template, created_at=datetime(2020, 12, 1, 9, 30))
notification_2 = create_notification(template=second_template, created_at=datetime(2020, 12, 1, 8, 30))
notification_3 = create_notification(template=third_template, created_at=datetime(2020, 12, 1, 8, 30))
results = dao_get_letters_to_be_printed(print_run_deadline=datetime(2020, 12, 1, 17, 30), postage='second')
assert len(results) == 2
assert notification_2 in results
assert notification_3 in results