mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 08:51:30 -05:00
Return count of notifications in the database for a job
When we cancel a job, we need to check if all notifications are already in the database. So far, we were querying for all notification objects in the database and counting them in admin app, which runs into pagination problems for large jobs, and could time out for very large jobs.
This commit is contained in:
@@ -178,6 +178,11 @@ def get_notifications_for_job(service_id, job_id, filter_dict=None, page=1, page
|
||||
)
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def dao_get_notification_count_for_job_id(job_id):
|
||||
return Notification.query.filter_by(job_id=job_id).count()
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def get_notification_with_personalisation(service_id, notification_id, key_type):
|
||||
filter_dict = {'service_id': service_id, 'id': notification_id}
|
||||
|
||||
Reference in New Issue
Block a user