mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Add new task to alert about created email / sms
This will log an error when email or SMS notifications have been stuck in 'created' for too long - normally they should be 'sending' in seconds, noting that we have a goal of < 10s wait time for most notifications being processed our platform. In the next commits we'll decouple similar functionality from the existing 'timeout-sending-notifications' task.
This commit is contained in:
@@ -30,6 +30,7 @@ from app.dao.jobs_dao import (
|
||||
find_missing_row_for_job,
|
||||
)
|
||||
from app.dao.notifications_dao import (
|
||||
dao_check_notifications_still_in_created,
|
||||
dao_old_letters_with_created_status,
|
||||
dao_precompiled_letters_still_pending_virus_check,
|
||||
is_delivery_slow_for_providers,
|
||||
@@ -118,6 +119,19 @@ def switch_current_sms_provider_on_slow_delivery():
|
||||
dao_reduce_sms_provider_priority(provider_name, time_threshold=timedelta(minutes=10))
|
||||
|
||||
|
||||
@notify_celery.task(name='raise-alert-if-email-sms-still-in-created')
|
||||
def raise_alert_if_email_sms_still_in_created():
|
||||
alert_above_age = current_app.config.get('CREATED_NOTIFICATIONS_ALERT_AGE')
|
||||
still_in_created = dao_check_notifications_still_in_created(alert_above_age)
|
||||
message = f"{still_in_created} notifications are still in 'created'."
|
||||
|
||||
if still_in_created == 0:
|
||||
current_app.logger.info(message)
|
||||
return
|
||||
|
||||
current_app.logger.error(message)
|
||||
|
||||
|
||||
@notify_celery.task(name='tend-providers-back-to-middle')
|
||||
def tend_providers_back_to_middle():
|
||||
dao_adjust_provider_priority_back_to_resting_points()
|
||||
|
||||
Reference in New Issue
Block a user