mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 15:15:38 -05:00
In the effort to reduce the number of database connections I introduced a small bug. This only affected the test templated letter flow, a None type error would happen when trying to creathe completed_at timestamp for a delivered message.
In the previous PR I removed the `update_notification` method to reduce the need for another update query. However, that meant the notification was marked as delivered without an updated_at timestamp. It is weird to set the updated_at when we create the notification. So is this a better fix? Or do I put the update back now? I recommend we push this fix now.
This commit is contained in:
@@ -347,6 +347,7 @@ def process_letter_notification(
|
||||
test_key = api_key.key_type == KEY_TYPE_TEST
|
||||
|
||||
status = NOTIFICATION_CREATED
|
||||
updated_at = None
|
||||
if test_key:
|
||||
# if we don't want to actually send the letter, then start it off in SENDING so we don't pick it up
|
||||
if current_app.config['NOTIFY_ENVIRONMENT'] in ['preview', 'development']:
|
||||
@@ -354,6 +355,7 @@ def process_letter_notification(
|
||||
# mark test letter as delivered and do not create a fake response later
|
||||
else:
|
||||
status = NOTIFICATION_DELIVERED
|
||||
updated_at = datetime.utcnow()
|
||||
|
||||
queue = QueueNames.CREATE_LETTERS_PDF if not test_key else QueueNames.RESEARCH_MODE
|
||||
|
||||
@@ -361,7 +363,9 @@ def process_letter_notification(
|
||||
template=template,
|
||||
api_key=api_key,
|
||||
status=status,
|
||||
reply_to_text=reply_to_text)
|
||||
reply_to_text=reply_to_text,
|
||||
updated_at=updated_at
|
||||
)
|
||||
|
||||
get_pdf_for_templated_letter.apply_async(
|
||||
[str(notification.id)],
|
||||
|
||||
Reference in New Issue
Block a user