diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index 84f9e1249..8976bbebc 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -689,11 +689,11 @@ def dao_old_letters_with_created_status(): last_processing_deadline = yesterday_bst.replace(hour=17, minute=30, second=0, microsecond=0) notifications = Notification.query.filter( - Notification.created_at < convert_bst_to_utc(last_processing_deadline), + Notification.updated_at < convert_bst_to_utc(last_processing_deadline), Notification.notification_type == LETTER_TYPE, Notification.status == NOTIFICATION_CREATED ).order_by( - Notification.created_at + Notification.updated_at ).all() return notifications diff --git a/tests/app/celery/test_scheduled_tasks.py b/tests/app/celery/test_scheduled_tasks.py index baf108380..f6081916f 100644 --- a/tests/app/celery/test_scheduled_tasks.py +++ b/tests/app/celery/test_scheduled_tasks.py @@ -376,12 +376,12 @@ def test_check_templated_letter_state_during_bst(mocker, sample_letter_template) mock_logger = mocker.patch('app.celery.tasks.current_app.logger.exception') mock_create_ticket = mocker.patch('app.celery.nightly_tasks.zendesk_client.create_ticket') - noti_1 = create_notification(template=sample_letter_template, created_at=datetime(2019, 5, 1, 12, 0)) - noti_2 = create_notification(template=sample_letter_template, created_at=datetime(2019, 5, 29, 16, 29)) - create_notification(template=sample_letter_template, created_at=datetime(2019, 5, 29, 16, 30)) - create_notification(template=sample_letter_template, created_at=datetime(2019, 5, 29, 17, 29)) - create_notification(template=sample_letter_template, status='delivered', created_at=datetime(2019, 5, 28, 10, 0)) - create_notification(template=sample_letter_template, created_at=datetime(2019, 5, 30, 10, 0)) + noti_1 = create_notification(template=sample_letter_template, updated_at=datetime(2019, 5, 1, 12, 0)) + noti_2 = create_notification(template=sample_letter_template, updated_at=datetime(2019, 5, 29, 16, 29)) + create_notification(template=sample_letter_template, updated_at=datetime(2019, 5, 29, 16, 30)) + create_notification(template=sample_letter_template, updated_at=datetime(2019, 5, 29, 17, 29)) + create_notification(template=sample_letter_template, status='delivered', updated_at=datetime(2019, 5, 28, 10, 0)) + create_notification(template=sample_letter_template, updated_at=datetime(2019, 5, 30, 10, 0)) check_templated_letter_state() @@ -401,12 +401,12 @@ def test_check_templated_letter_state_during_utc(mocker, sample_letter_template) mock_logger = mocker.patch('app.celery.tasks.current_app.logger.exception') mock_create_ticket = mocker.patch('app.celery.nightly_tasks.zendesk_client.create_ticket') - noti_1 = create_notification(template=sample_letter_template, created_at=datetime(2018, 12, 1, 12, 0)) - noti_2 = create_notification(template=sample_letter_template, created_at=datetime(2019, 1, 29, 17, 29)) - create_notification(template=sample_letter_template, created_at=datetime(2019, 1, 29, 17, 30)) - create_notification(template=sample_letter_template, created_at=datetime(2019, 1, 29, 18, 29)) - create_notification(template=sample_letter_template, status='delivered', created_at=datetime(2019, 1, 29, 10, 0)) - create_notification(template=sample_letter_template, created_at=datetime(2019, 1, 30, 10, 0)) + noti_1 = create_notification(template=sample_letter_template, updated_at=datetime(2018, 12, 1, 12, 0)) + noti_2 = create_notification(template=sample_letter_template, updated_at=datetime(2019, 1, 29, 17, 29)) + create_notification(template=sample_letter_template, updated_at=datetime(2019, 1, 29, 17, 30)) + create_notification(template=sample_letter_template, updated_at=datetime(2019, 1, 29, 18, 29)) + create_notification(template=sample_letter_template, status='delivered', updated_at=datetime(2019, 1, 29, 10, 0)) + create_notification(template=sample_letter_template, updated_at=datetime(2019, 1, 30, 10, 0)) check_templated_letter_state()