mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-13 16:52:23 -05:00
Add scheduled task to find old letters which still have 'created' status
Added a scheduled task to run once a day and check if there were any letters from before 17.30 that still have a status of 'created'. This logs an exception instead of trying to fix the error because the fix will be different depending on which bucket the letter is in.
This commit is contained in:
@@ -21,6 +21,7 @@ from app.dao.notifications_dao import (
|
||||
set_scheduled_notification_to_processed,
|
||||
notifications_not_yet_sent,
|
||||
dao_precompiled_letters_still_pending_virus_check,
|
||||
dao_old_letters_with_created_status,
|
||||
)
|
||||
from app.dao.provider_details_dao import (
|
||||
get_current_provider,
|
||||
@@ -193,3 +194,17 @@ def check_precompiled_letter_state():
|
||||
len(letters),
|
||||
letter_ids)
|
||||
)
|
||||
|
||||
|
||||
@notify_celery.task(name='check-templated-letter-state')
|
||||
@statsd(namespace="tasks")
|
||||
def check_templated_letter_state():
|
||||
letters = dao_old_letters_with_created_status()
|
||||
letter_ids = [str(letter.id) for letter in letters]
|
||||
|
||||
if len(letters) > 0:
|
||||
current_app.logger.exception(
|
||||
"{} letters were created before 17.30 yesterday and still have 'created' state. Notifications: {}".format(
|
||||
len(letters),
|
||||
letter_ids)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user