From 6dad9b43dbc76a26a647998d37b849d93c19c345 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Fri, 23 Mar 2018 15:47:01 +0000 Subject: [PATCH 1/2] New command to create-pdf-letter task for a given notification id. After a notificaiton is created we create a task to create the pdf and save it to S3, if for some reason that task does not run we are left with notifications that are not sent. This should not happen, but if it does we have a way to continue sending the letter. --- app/commands.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/commands.py b/app/commands.py index 74f002c7f..abe44dbea 100644 --- a/app/commands.py +++ b/app/commands.py @@ -12,6 +12,7 @@ from sqlalchemy.orm.exc import NoResultFound from app import db, DATETIME_FORMAT, encryption from app.celery.scheduled_tasks import send_total_sent_notifications_to_performance_platform from app.celery.service_callback_tasks import send_delivery_status_to_service +from app.celery.letters_pdf_tasks import create_letters_pdf from app.config import QueueNames from app.dao.monthly_billing_dao import ( create_or_update_monthly_billing, @@ -316,6 +317,14 @@ def insert_inbound_numbers_from_file(file_name): file.close() +@notify_command(name='replay-create-pdf-letters') +@click.option('-n', '--notification_id', required=True, + help="Notification id of the letter that needs the create_letters_pdf task replayed") +def replay_create_pdf_letters(notification_id): + print("Create task to create_letters_pdf for notification: {}".format(notification_id)) + create_letters_pdf.apply_async([notification_id], queue=QueueNames.CREATE_LETTERS_PDF) + + @notify_command(name='replay-service-callbacks') @click.option('-f', '--file_name', required=True, help="""Full path of the file to upload, file is a contains client references of From fc21121764e6b356b17438863c5d6e8d5cc78b98 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Fri, 23 Mar 2018 16:11:43 +0000 Subject: [PATCH 2/2] Check input is a UUID --- app/commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/commands.py b/app/commands.py index abe44dbea..bf90623ca 100644 --- a/app/commands.py +++ b/app/commands.py @@ -318,11 +318,11 @@ def insert_inbound_numbers_from_file(file_name): @notify_command(name='replay-create-pdf-letters') -@click.option('-n', '--notification_id', required=True, +@click.option('-n', '--notification_id', type=click.UUID, required=True, help="Notification id of the letter that needs the create_letters_pdf task replayed") def replay_create_pdf_letters(notification_id): print("Create task to create_letters_pdf for notification: {}".format(notification_id)) - create_letters_pdf.apply_async([notification_id], queue=QueueNames.CREATE_LETTERS_PDF) + create_letters_pdf.apply_async([str(notification_id)], queue=QueueNames.CREATE_LETTERS_PDF) @notify_command(name='replay-service-callbacks')