mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
Update update_notification_status_by_id DAO function
Replaced `.with_for_lockmode()`, which is now deprecated, with `.with_for_update() - https://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.with_lockmode The function should update any statuses that are not 'final', so added `pending-virus-check` to the list of statuses that the function can update.
This commit is contained in:
@@ -39,6 +39,7 @@ from app.models import (
|
||||
NOTIFICATION_DELIVERED,
|
||||
NOTIFICATION_SENDING,
|
||||
NOTIFICATION_PENDING,
|
||||
NOTIFICATION_PENDING_VIRUS_CHECK,
|
||||
NOTIFICATION_TECHNICAL_FAILURE,
|
||||
NOTIFICATION_TEMPORARY_FAILURE,
|
||||
NOTIFICATION_PERMANENT_FAILURE,
|
||||
@@ -145,13 +146,14 @@ def _update_notification_status(notification, status):
|
||||
@statsd(namespace="dao")
|
||||
@transactional
|
||||
def update_notification_status_by_id(notification_id, status, sent_by=None):
|
||||
notification = Notification.query.with_lockmode("update").filter(
|
||||
notification = Notification.query.with_for_update().filter(
|
||||
Notification.id == notification_id,
|
||||
or_(
|
||||
Notification.status == NOTIFICATION_CREATED,
|
||||
Notification.status == NOTIFICATION_SENDING,
|
||||
Notification.status == NOTIFICATION_PENDING,
|
||||
Notification.status == NOTIFICATION_SENT
|
||||
Notification.status == NOTIFICATION_SENT,
|
||||
Notification.status == NOTIFICATION_PENDING_VIRUS_CHECK
|
||||
)).first()
|
||||
|
||||
if not notification:
|
||||
|
||||
Reference in New Issue
Block a user