mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
Add scheduled task to send scheduled notifcations.
Fix the query to fetch scheduled notifications.
This commit is contained in:
@@ -14,13 +14,14 @@ from app.dao.jobs_dao import dao_set_scheduled_jobs_to_pending, dao_get_jobs_old
|
||||
from app.dao.notifications_dao import (
|
||||
delete_notifications_created_more_than_a_week_ago,
|
||||
dao_timeout_notifications,
|
||||
is_delivery_slow_for_provider
|
||||
)
|
||||
is_delivery_slow_for_provider,
|
||||
dao_get_scheduled_notifications)
|
||||
from app.dao.provider_details_dao import (
|
||||
get_current_provider,
|
||||
dao_toggle_sms_provider
|
||||
)
|
||||
from app.dao.users_dao import delete_codes_older_created_more_than_a_day_ago
|
||||
from app.notifications.process_notifications import send_notification_to_queue
|
||||
from app.statsd_decorators import statsd
|
||||
from app.celery.tasks import process_job
|
||||
|
||||
@@ -46,6 +47,18 @@ def run_scheduled_jobs():
|
||||
raise
|
||||
|
||||
|
||||
@notify_celery.task(name='send-scheduled-notifications')
|
||||
@statsd(namespace="tasks")
|
||||
def send_scheduled_notifications():
|
||||
try:
|
||||
for notification in dao_get_scheduled_notifications():
|
||||
send_notification_to_queue(notification, notification.service.research_mode)
|
||||
|
||||
except SQLAlchemyError as e:
|
||||
current_app.logger.exception("Failed to send scheduled notifications")
|
||||
raise
|
||||
|
||||
|
||||
@notify_celery.task(name="delete-verify-codes")
|
||||
@statsd(namespace="tasks")
|
||||
def delete_verify_codes():
|
||||
|
||||
Reference in New Issue
Block a user