mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 18:01:08 -05:00
Add an endpoint for stats about scheduled jobs
At the moment we display the count of scheduled jobs on the dashboard by sending all the scheduled jobs to the admin app and letting it work out the stats. This is inefficient and, because the get jobs response has a page size of 50, becomes incorrect if a service schedules more than 50 jobs. This commit adds a separate endpoint which gives the admin app the stats it needs directly and correctly.
This commit is contained in:
@@ -84,6 +84,18 @@ def dao_get_jobs_by_service_id(
|
||||
.paginate(page=page, per_page=page_size)
|
||||
|
||||
|
||||
def dao_get_scheduled_job_stats(
|
||||
service_id,
|
||||
):
|
||||
return db.session.query(
|
||||
func.count(Job.id),
|
||||
func.min(Job.scheduled_for),
|
||||
).filter(
|
||||
Job.service_id == service_id,
|
||||
Job.job_status == JOB_STATUS_SCHEDULED,
|
||||
).one()
|
||||
|
||||
|
||||
def dao_get_job_by_id(job_id):
|
||||
return Job.query.filter_by(id=job_id).one()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user