diff --git a/app/celery/scheduled_tasks.py b/app/celery/scheduled_tasks.py index 5bac860a6..c6a36aca9 100644 --- a/app/celery/scheduled_tasks.py +++ b/app/celery/scheduled_tasks.py @@ -447,3 +447,22 @@ def daily_stats_template_usage_by_month(): result.year, result.count ) + + +@notify_celery.task(name='raise-alert-if-no-letter-ack-file') +@statsd(namespace="tasks") +def raise_alert_if_no_letter_ack_file(): + """ + Get all files sent "today" + list_of_zip_files => get file names s3.get_s3_bucket_objects() look in the folder with todays date + + list_of_ack_files => Get all files sent today with name containing ack.txt from a diff bucket + + For filename in list_of_zip_files: + for ack_file in list_of_ack_files if name= file.strip("NOTIFY.", ".ZIP") + IF no ack_file + raise NoAckFileReceived(status=500, message="No ack file received for {filename}") + + """ + + pass \ No newline at end of file diff --git a/app/config.py b/app/config.py index 42ba4177e..25a2cd80a 100644 --- a/app/config.py +++ b/app/config.py @@ -249,6 +249,11 @@ class Config(object): 'schedule': crontab(hour=17, minute=50), 'options': {'queue': QueueNames.PERIODIC} }, + 'raise-alert-if-no-letter-ack-file': { + 'task': 'raise-alert-if-no-letter-ack-file', + 'schedule': crontab(hour=19, minute=00), + 'options': {'queue': QueueNames.PERIODIC} + }, 'run-letter-api-notifications': { 'task': 'run-letter-api-notifications', 'schedule': crontab(hour=17, minute=40), diff --git a/app/notifications/notifications_letter_callback.py b/app/notifications/notifications_letter_callback.py index ac2de9e5c..06d24a40f 100644 --- a/app/notifications/notifications_letter_callback.py +++ b/app/notifications/notifications_letter_callback.py @@ -53,6 +53,7 @@ def process_letter_response(): message = json.loads(req_json['Message']) filename = message['Records'][0]['s3']['object']['key'] current_app.logger.info('Received file from DVLA: {}'.format(filename)) + # IF file name contains .rs.txt THEN continue ELSE log message with file name. and return current_app.logger.info('DVLA callback: Calling task to update letter notifications') update_letter_notifications_statuses.apply_async([filename], queue=QueueNames.NOTIFY)