mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-04 05:30:53 -04:00
Added updated_at to the update query
This commit is contained in:
@@ -295,13 +295,14 @@ def dao_delete_notifications_and_history_by_id(notification_id):
|
||||
def dao_timeout_notifications(timeout_period_in_seconds):
|
||||
# update all notifications that are older that the timeout_period_in_seconds
|
||||
# with a status of created|sending|pending
|
||||
update_at = datetime.utcnow()
|
||||
updated = db.session.query(Notification). \
|
||||
filter(Notification.created_at < (datetime.utcnow() - timedelta(seconds=timeout_period_in_seconds))). \
|
||||
filter(Notification.status.in_([NOTIFICATION_CREATED, NOTIFICATION_SENDING, NOTIFICATION_PENDING])). \
|
||||
update({'status': NOTIFICATION_TEMPORARY_FAILURE}, synchronize_session=False)
|
||||
update({'status': NOTIFICATION_TEMPORARY_FAILURE, 'updated_at': update_at}, synchronize_session=False)
|
||||
db.session.query(NotificationHistory). \
|
||||
filter(NotificationHistory.created_at < (datetime.utcnow() - timedelta(seconds=timeout_period_in_seconds))). \
|
||||
filter(NotificationHistory.status.in_([NOTIFICATION_CREATED, NOTIFICATION_SENDING, NOTIFICATION_PENDING])). \
|
||||
update({'status': NOTIFICATION_TEMPORARY_FAILURE}, synchronize_session=False)
|
||||
update({'status': NOTIFICATION_TEMPORARY_FAILURE, 'updated_at': update_at}, synchronize_session=False)
|
||||
db.session.commit()
|
||||
return updated
|
||||
|
||||
Reference in New Issue
Block a user