Skip to content
Snippets Groups Projects
Commit a22421b5 authored by Ian's avatar Ian
Browse files

refactor: JobLedger.get_pending_jobs() sorts by recency

parent 5d7164a4
No related branches found
No related tags found
No related merge requests found
......@@ -37,12 +37,19 @@ class JobLedger:
def get_pending_jobs(self) -> List[Job]:
"""Get jobs not in final states"""
return [
# Get all unfinished jobs
pending = [
job
for job_id, job in self.jobs.items()
if self.status[job_id] not in self.FINAL_STATES
]
# Sort by last checked time, most recently checked last
pending.sort(key=lambda x: self.last_checked[x.job_id])
return pending
def get_finished_jobs(self) -> List[Job]:
"""Get only finished jobs"""
return [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment