mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Allow jobs to be filtered by contact list
Rather than showing all jobs that have been ‘copied’ from a contact list I think it makes more sense to group them under the contact list. This way it’s easier to see what messages have been sent to a given group of contacts over time. Part of this work means the API needs to return only jobs that have been created from a given contact list, when asked.
This commit is contained in:
@@ -65,6 +65,7 @@ def dao_get_jobs_by_service_id(
|
||||
page=1,
|
||||
page_size=50,
|
||||
statuses=None,
|
||||
contact_list_id=None,
|
||||
):
|
||||
query_filter = [
|
||||
Job.service_id == service_id,
|
||||
@@ -77,6 +78,8 @@ def dao_get_jobs_by_service_id(
|
||||
query_filter.append(
|
||||
Job.job_status.in_(statuses)
|
||||
)
|
||||
if contact_list_id is not None:
|
||||
query_filter.append(Job.contact_list_id == contact_list_id)
|
||||
return Job.query \
|
||||
.filter(*query_filter) \
|
||||
.order_by(Job.processing_started.desc(), Job.created_at.desc()) \
|
||||
|
||||
Reference in New Issue
Block a user