mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-02 17:48:36 -04:00
add statuses filter to GET /service/{}/job
can now pass in a query string `?statuses=x,y,z` to filter jobs based on `Job.job_status`. Not passing in a status or passing in an empty string is equivalent to selecting every filter type at once.
This commit is contained in:
@@ -102,8 +102,10 @@ def get_jobs_by_service(service_id):
|
||||
else:
|
||||
limit_days = None
|
||||
|
||||
statuses = [x.strip() for x in request.args.get('statuses', '').split(',')]
|
||||
|
||||
page = int(request.args.get('page', 1))
|
||||
return jsonify(**get_paginated_jobs(service_id, limit_days, page))
|
||||
return jsonify(**get_paginated_jobs(service_id, limit_days, statuses, page))
|
||||
|
||||
|
||||
@job.route('', methods=['POST'])
|
||||
@@ -140,14 +142,14 @@ def create_job(service_id):
|
||||
return jsonify(data=job_json), 201
|
||||
|
||||
|
||||
def get_paginated_jobs(service_id, limit_days, page):
|
||||
def get_paginated_jobs(service_id, limit_days, statuses, page):
|
||||
pagination = dao_get_jobs_by_service_id(
|
||||
service_id,
|
||||
limit_days=limit_days,
|
||||
page=page,
|
||||
page_size=current_app.config['PAGE_SIZE']
|
||||
page_size=current_app.config['PAGE_SIZE'],
|
||||
statuses=statuses
|
||||
)
|
||||
|
||||
data = job_schema.dump(pagination.items, many=True).data
|
||||
for job_data in data:
|
||||
statistics = dao_get_notification_outcomes_for_job(service_id, job_data['id'])
|
||||
|
||||
Reference in New Issue
Block a user