mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-06 22:58:25 -04:00
Add beat config for send-scheduled-notifications task to run every 15 minutes.
Added the missing commit to the update pending
This commit is contained in:
@@ -44,7 +44,7 @@ def run_scheduled_jobs():
|
|||||||
for job in dao_set_scheduled_jobs_to_pending():
|
for job in dao_set_scheduled_jobs_to_pending():
|
||||||
process_job.apply_async([str(job.id)], queue="process-job")
|
process_job.apply_async([str(job.id)], queue="process-job")
|
||||||
current_app.logger.info("Job ID {} added to process job queue".format(job.id))
|
current_app.logger.info("Job ID {} added to process job queue".format(job.id))
|
||||||
except SQLAlchemyError as e:
|
except SQLAlchemyError:
|
||||||
current_app.logger.exception("Failed to run scheduled jobs")
|
current_app.logger.exception("Failed to run scheduled jobs")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@@ -58,8 +58,8 @@ def send_scheduled_notifications():
|
|||||||
send_notification_to_queue(notification, notification.service.research_mode)
|
send_notification_to_queue(notification, notification.service.research_mode)
|
||||||
set_scheduled_notification_to_processed(notification.id)
|
set_scheduled_notification_to_processed(notification.id)
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
"Sent {} scheudled notifications to the provider queue".format(len(scheduled_notifications)))
|
"Sent {} scheduled notifications to the provider queue".format(len(scheduled_notifications)))
|
||||||
except SQLAlchemyError as e:
|
except SQLAlchemyError:
|
||||||
current_app.logger.exception("Failed to send scheduled notifications")
|
current_app.logger.exception("Failed to send scheduled notifications")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,11 @@ class Config(object):
|
|||||||
'schedule': crontab(minute=1),
|
'schedule': crontab(minute=1),
|
||||||
'options': {'queue': 'periodic'}
|
'options': {'queue': 'periodic'}
|
||||||
},
|
},
|
||||||
|
'send-scheduled-notifications': {
|
||||||
|
'task': 'send-scheduled-notifications',
|
||||||
|
'schedule': crontab(minute='*/15'),
|
||||||
|
'options': {'queue': 'periodic'}
|
||||||
|
},
|
||||||
'delete-verify-codes': {
|
'delete-verify-codes': {
|
||||||
'task': 'delete-verify-codes',
|
'task': 'delete-verify-codes',
|
||||||
'schedule': timedelta(minutes=63),
|
'schedule': timedelta(minutes=63),
|
||||||
|
|||||||
@@ -483,8 +483,9 @@ def dao_get_scheduled_notifications():
|
|||||||
|
|
||||||
|
|
||||||
def set_scheduled_notification_to_processed(notification_id):
|
def set_scheduled_notification_to_processed(notification_id):
|
||||||
ScheduledNotification.query.filter(
|
db.session.query(ScheduledNotification).filter(
|
||||||
ScheduledNotification.notification_id == notification_id
|
ScheduledNotification.notification_id == notification_id
|
||||||
).update(
|
).update(
|
||||||
{'pending': False}
|
{'pending': False}
|
||||||
)
|
)
|
||||||
|
db.session.commit()
|
||||||
|
|||||||
Reference in New Issue
Block a user