Returns the outcome statistics for the job on the API call.

This commit is contained in:
Martyn Inglis
2016-08-23 16:46:58 +01:00
parent 270451e7ba
commit 09cb94081b
5 changed files with 197 additions and 22 deletions

View File

@@ -8,7 +8,8 @@ from flask import (
from app.dao.jobs_dao import (
dao_create_job,
dao_get_job_by_service_id_and_job_id,
dao_get_jobs_by_service_id
dao_get_jobs_by_service_id,
dao_get_notification_outcomes_for_job
)
from app.dao.services_dao import (
@@ -42,7 +43,11 @@ register_errors(job)
@job.route('/<job_id>', methods=['GET'])
def get_job_by_service_and_job_id(service_id, job_id):
job = dao_get_job_by_service_id_and_job_id(service_id, job_id)
statistics = dao_get_notification_outcomes_for_job(service_id, job_id)
data = job_schema.dump(job).data
data['statistics'] = [{'status': statistic[1], 'count': statistic[0]} for statistic in statistics]
return jsonify(data=data)