mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Revert "trigger nightly delete tasks from the create notification status task"
This reverts commit 58f24a0a83.
This commit is contained in:
@@ -12,11 +12,6 @@ from app.dao.fact_billing_dao import (
|
|||||||
update_fact_billing
|
update_fact_billing
|
||||||
)
|
)
|
||||||
from app.dao.fact_notification_status_dao import fetch_notification_status_for_day, update_fact_notification_status
|
from app.dao.fact_notification_status_dao import fetch_notification_status_for_day, update_fact_notification_status
|
||||||
from app.celery.nightly_tasks import (
|
|
||||||
delete_sms_notifications_older_than_retention,
|
|
||||||
delete_email_notifications_older_than_retention,
|
|
||||||
delete_letter_notifications_older_than_retention
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@notify_celery.task(name="create-nightly-billing")
|
@notify_celery.task(name="create-nightly-billing")
|
||||||
|
|||||||
@@ -222,6 +222,21 @@ class Config(object):
|
|||||||
'schedule': crontab(hour=0, minute=30), # after 'timeout-sending-notifications'
|
'schedule': crontab(hour=0, minute=30), # after 'timeout-sending-notifications'
|
||||||
'options': {'queue': QueueNames.REPORTING}
|
'options': {'queue': QueueNames.REPORTING}
|
||||||
},
|
},
|
||||||
|
'delete-sms-notifications': {
|
||||||
|
'task': 'delete-sms-notifications',
|
||||||
|
'schedule': crontab(hour=0, minute=45), # after 'create-nightly-notification-status'
|
||||||
|
'options': {'queue': QueueNames.PERIODIC}
|
||||||
|
},
|
||||||
|
'delete-email-notifications': {
|
||||||
|
'task': 'delete-email-notifications',
|
||||||
|
'schedule': crontab(hour=1, minute=0), # after 'create-nightly-notification-status'
|
||||||
|
'options': {'queue': QueueNames.PERIODIC}
|
||||||
|
},
|
||||||
|
'delete-letter-notifications': {
|
||||||
|
'task': 'delete-letter-notifications',
|
||||||
|
'schedule': crontab(hour=1, minute=20), # after 'create-nightly-notification-status'
|
||||||
|
'options': {'queue': QueueNames.PERIODIC}
|
||||||
|
},
|
||||||
'delete-inbound-sms': {
|
'delete-inbound-sms': {
|
||||||
'task': 'delete-inbound-sms',
|
'task': 'delete-inbound-sms',
|
||||||
'schedule': crontab(hour=1, minute=40),
|
'schedule': crontab(hour=1, minute=40),
|
||||||
|
|||||||
@@ -434,13 +434,7 @@ def test_create_nightly_billing_for_day_update_when_record_exists(
|
|||||||
|
|
||||||
|
|
||||||
@freeze_time('2019-01-05')
|
@freeze_time('2019-01-05')
|
||||||
def test_create_nightly_notification_status_for_day(notify_db_session, mocker):
|
def test_create_nightly_notification_status_for_day(notify_db_session):
|
||||||
mocks = [
|
|
||||||
mocker.patch('app.celery.reporting_tasks.delete_email_notifications_older_than_retention'),
|
|
||||||
mocker.patch('app.celery.reporting_tasks.delete_sms_notifications_older_than_retention'),
|
|
||||||
mocker.patch('app.celery.reporting_tasks.delete_letter_notifications_older_than_retention'),
|
|
||||||
]
|
|
||||||
|
|
||||||
first_service = create_service(service_name='First Service')
|
first_service = create_service(service_name='First Service')
|
||||||
first_template = create_template(service=first_service)
|
first_template = create_template(service=first_service)
|
||||||
second_service = create_service(service_name='second Service')
|
second_service = create_service(service_name='second Service')
|
||||||
@@ -468,17 +462,10 @@ def test_create_nightly_notification_status_for_day(notify_db_session, mocker):
|
|||||||
assert new_data[1].bst_date == date(2019, 1, 1)
|
assert new_data[1].bst_date == date(2019, 1, 1)
|
||||||
assert new_data[2].bst_date == date(2019, 1, 1)
|
assert new_data[2].bst_date == date(2019, 1, 1)
|
||||||
|
|
||||||
for mock in mocks:
|
|
||||||
mock.apply_async.assert_called_once_with(queue='periodic-tasks')
|
|
||||||
|
|
||||||
|
|
||||||
# the job runs at 12:30am London time. 04/01 is in BST.
|
# the job runs at 12:30am London time. 04/01 is in BST.
|
||||||
@freeze_time('2019-04-01T23:30')
|
@freeze_time('2019-04-01T23:30')
|
||||||
def test_create_nightly_notification_status_for_day_respects_bst(sample_template, mocker):
|
def test_create_nightly_notification_status_for_day_respects_bst(sample_template):
|
||||||
mocker.patch('app.celery.reporting_tasks.delete_email_notifications_older_than_retention')
|
|
||||||
mocker.patch('app.celery.reporting_tasks.delete_sms_notifications_older_than_retention')
|
|
||||||
mocker.patch('app.celery.reporting_tasks.delete_letter_notifications_older_than_retention')
|
|
||||||
|
|
||||||
create_notification(sample_template, status='delivered', created_at=datetime(2019, 4, 1, 23, 0)) # too new
|
create_notification(sample_template, status='delivered', created_at=datetime(2019, 4, 1, 23, 0)) # too new
|
||||||
|
|
||||||
create_notification(sample_template, status='created', created_at=datetime(2019, 4, 1, 22, 59))
|
create_notification(sample_template, status='created', created_at=datetime(2019, 4, 1, 22, 59))
|
||||||
|
|||||||
Reference in New Issue
Block a user