mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Sort jobs by processed time first
Say you have a dashboard with some jobs you sent. Normally looks like: job | sent --- | --- file.csv | **5pm** file.csv | 3pm file.csv | 1pm file.csv | 11am However if your 5pm job was scheduled at lunchtime, then it will look like this: job | sent --- | --- file.csv | 3pm file.csv | 1pm file.csv | **5pm** file.csv | 11am This is because the jobs are sorted by when they were created, not when they were sent. It looks wrong. **For jobs that have already been sent** This commit changes the sort order to be based on `processed_at` instead. **For upcoming jobs** If a job doesn’t have a `processed_at` time then it’s scheduled, but hasn’t started yet. Only in this case should we still be sorting by `created_at`.
This commit is contained in:
@@ -37,7 +37,7 @@ def dao_get_jobs_by_service_id(service_id, limit_days=None, page=1, page_size=50
|
||||
)
|
||||
return Job.query \
|
||||
.filter(*query_filter) \
|
||||
.order_by(desc(Job.created_at)) \
|
||||
.order_by(Job.processing_started.desc(), Job.created_at.desc()) \
|
||||
.paginate(page=page, per_page=page_size)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user