mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 08:21:13 -05:00
This massive set of changes uses the new queue names object throughout the app and tests.
Lots of changes, all changing the line of code that puts things into queues, and the code that tests that.
This commit is contained in:
@@ -3,7 +3,6 @@ from sqlalchemy.exc import SQLAlchemyError
|
||||
from app import notify_celery
|
||||
from flask import current_app
|
||||
|
||||
from app.models import JobStatistics
|
||||
from app.statsd_decorators import statsd
|
||||
from app.dao.statistics_dao import (
|
||||
create_or_update_job_sending_statistics,
|
||||
@@ -11,16 +10,17 @@ from app.dao.statistics_dao import (
|
||||
)
|
||||
from app.dao.notifications_dao import get_notification_by_id
|
||||
from app.models import NOTIFICATION_STATUS_TYPES_COMPLETED
|
||||
from app.config import QueueNames
|
||||
|
||||
|
||||
def create_initial_notification_statistic_tasks(notification):
|
||||
if notification.job_id and notification.status:
|
||||
record_initial_job_statistics.apply_async((str(notification.id),), queue="statistics")
|
||||
record_initial_job_statistics.apply_async((str(notification.id),), queue=QueueNames.STATISTICS)
|
||||
|
||||
|
||||
def create_outcome_notification_statistic_tasks(notification):
|
||||
if notification.job_id and notification.status in NOTIFICATION_STATUS_TYPES_COMPLETED:
|
||||
record_outcome_job_statistics.apply_async((str(notification.id),), queue="statistics")
|
||||
record_outcome_job_statistics.apply_async((str(notification.id),), queue=QueueNames.STATISTICS)
|
||||
|
||||
|
||||
@notify_celery.task(bind=True, name='record_initial_job_statistics', max_retries=20, default_retry_delay=10)
|
||||
@@ -35,7 +35,7 @@ def record_initial_job_statistics(self, notification_id):
|
||||
raise SQLAlchemyError("Failed to find notification with id {}".format(notification_id))
|
||||
except SQLAlchemyError as e:
|
||||
current_app.logger.exception(e)
|
||||
self.retry(queue="retry")
|
||||
self.retry(queue=QueueNames.RETRY)
|
||||
except self.MaxRetriesExceededError:
|
||||
current_app.logger.error(
|
||||
"RETRY FAILED: task record_initial_job_statistics failed for notification {}".format(
|
||||
@@ -53,12 +53,12 @@ def record_outcome_job_statistics(self, notification_id):
|
||||
if notification:
|
||||
updated_count = update_job_stats_outcome_count(notification)
|
||||
if updated_count == 0:
|
||||
self.retry(queue="retry")
|
||||
self.retry(queue=QueueNames.RETRY)
|
||||
else:
|
||||
raise SQLAlchemyError("Failed to find notification with id {}".format(notification_id))
|
||||
except SQLAlchemyError as e:
|
||||
current_app.logger.exception(e)
|
||||
self.retry(queue="retry")
|
||||
self.retry(queue=QueueNames.RETRY)
|
||||
except self.MaxRetriesExceededError:
|
||||
current_app.logger.error(
|
||||
"RETRY FAILED: task update_job_stats_outcome_count failed for notification {}".format(
|
||||
|
||||
Reference in New Issue
Block a user