Fix the folder returned for a pdf letter.

Using the created at date for the folder is not always going to work because the pdf created_at date could be just before the cut off date but virus scan and validation has yet to happen. By the time the letters is in the created state, the letter goes into the next days bucket.
It can also happen if the letters is stuck in `pending-virus-scan` and we need to restart the task, and the letters is in a different folder.
This commit is contained in:
Rebecca Law
2019-09-05 11:47:31 +01:00
parent c953ef5223
commit a772fb8acf
2 changed files with 19 additions and 1 deletions

View File

@@ -58,7 +58,10 @@ def get_bucket_name_and_prefix_for_notification(notification):
bucket_name = current_app.config['TEST_LETTERS_BUCKET_NAME']
else:
bucket_name = current_app.config['LETTERS_PDF_BUCKET_NAME']
folder = get_folder_name(notification.created_at, False)
if notification.sent_at:
folder = "{}/".format(notification.sent_at.date())
else:
folder = get_folder_name(notification.updated_at, False)
upload_file_name = PRECOMPILED_BUCKET_PREFIX.format(
folder=folder,