From 9549ada200a767c54a7ac2c8c91db5dd8a2fd0c7 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Mon, 26 Mar 2018 10:26:24 +0100 Subject: [PATCH] Run task every 15 minutes. Move variable to task from config. --- app/celery/scheduled_tasks.py | 4 +++- app/config.py | 9 +++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/celery/scheduled_tasks.py b/app/celery/scheduled_tasks.py index 07f91a1d4..a979c418c 100644 --- a/app/celery/scheduled_tasks.py +++ b/app/celery/scheduled_tasks.py @@ -543,9 +543,11 @@ def letter_raise_alert_if_no_ack_file_for_zip(): @notify_celery.task(name='replay-created-notifications') @statsd(namespace="tasks") def replay_created_notifications(): + # if the notification has not be send after 4 hours + 15 minutes, then try to resend. + resend_created_notifications_older_than = (60 * 60 * 4) + (60 * 15) for notification_type in (EMAIL_TYPE, SMS_TYPE): notifications_to_resend = notifications_not_yet_sent( - current_app.config.get("RESEND_CREATED_NOTIFICATIONS_OLDER_THAN"), + resend_created_notifications_older_than, notification_type ) diff --git a/app/config.py b/app/config.py index 67d047ed8..fce2c0a35 100644 --- a/app/config.py +++ b/app/config.py @@ -267,9 +267,9 @@ class Config(object): 'schedule': crontab(hour=0, minute=5), 'options': {'queue': QueueNames.PERIODIC} }, - 'replay_created_notifications': { - 'task': 'replay_created_notifications', - 'schedule': crontab(minutes=15), + 'replay-created-notifications': { + 'task': 'replay-created-notifications', + 'schedule': crontab(minute='0, 15, 24, 30, 45'), 'options': {'queue': QueueNames.PERIODIC} } } @@ -284,9 +284,6 @@ class Config(object): SENDING_NOTIFICATIONS_TIMEOUT_PERIOD = 259200 # 3 days - RESEND_CREATED_NOTIFICATIONS_OLDER_THAN = (60 * 60 * 4) + (60 * 15) - RESEND_LETTER_CREATED_NOTIFICATIONS_OLDER_THAN_DAYS = 2 - SIMULATED_EMAIL_ADDRESSES = ( 'simulate-delivered@notifications.service.gov.uk', 'simulate-delivered-2@notifications.service.gov.uk',