Skip to content

Commit

Permalink
feat: add queue index to progress api
Browse files Browse the repository at this point in the history
Signed-off-by: AnyISalIn <[email protected]>
  • Loading branch information
AnyISalIn committed Aug 21, 2023
1 parent 541ef92 commit 0955cd7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ def progressapi(req: ProgressRequest):
completed = req.id_task in finished_tasks

if not active:
return ProgressResponse(active=active, queued=queued, completed=completed, id_live_preview=-1, textinfo="In queue..." if queued else "Waiting...")
textinfo = "Waiting..."
if queued:
sorted_queued = sorted(pending_tasks.keys(), key=lambda x: pending_tasks[x], reverse=True)
queue_index = sorted_queued.index(req.id_task)
textinfo = "In queue: {}/{}".format(queue_index + 1, len(sorted_queued))
return ProgressResponse(active=active, queued=queued, completed=completed, id_live_preview=-1, textinfo=textinfo)

progress = 0

Expand Down

0 comments on commit 0955cd7

Please sign in to comment.