mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Refactor update to notifcations to be a bulk update. This is much better for performance.
This commit is contained in:
@@ -439,3 +439,18 @@ def is_delivery_slow_for_provider(
|
||||
(Notification.updated_at - Notification.sent_at) >= delivery_time,
|
||||
).count()
|
||||
return count >= threshold
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
@transactional
|
||||
def dao_update_notifications_sent_to_dvla(job_id, provider):
|
||||
updated_count = db.session.query(Notification
|
||||
).filter(Notification.job_id == job_id
|
||||
).update({'status': 'sending', "sent_by": provider})
|
||||
# only update NotificationHistory if api key typ is not test
|
||||
db.session.query(NotificationHistory
|
||||
).filter(NotificationHistory.job_id == job_id,
|
||||
NotificationHistory.key_type != KEY_TYPE_TEST
|
||||
).update({'status': 'sending', "sent_by": provider})
|
||||
|
||||
return updated_count
|
||||
|
||||
Reference in New Issue
Block a user