From 040d6896a3cd5622e78cccdedd8cce2afcf49a31 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sun, 13 Dec 2020 19:27:25 +0100 Subject: add display of logs matching any state --- server/lib/job-queue/job-queue.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'server/lib/job-queue') diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts index 8d97434ac..49f06584d 100644 --- a/server/lib/job-queue/job-queue.ts +++ b/server/lib/job-queue/job-queue.ts @@ -154,13 +154,13 @@ class JobQueue { } async listForApi (options: { - state: JobState + state: JobState | JobState[] start: number count: number asc?: boolean jobType: JobType }): Promise { - const { state, start, count, asc, jobType } = options + const { state = Array.isArray(options.state) ? options.state : [ options.state ], start, count, asc, jobType } = options let results: Bull.Job[] = [] const filteredJobTypes = this.filterJobTypes(jobType) @@ -172,7 +172,7 @@ class JobQueue { continue } - const jobs = await queue.getJobs([ state ], 0, start + count, asc) + const jobs = await queue.getJobs(state as Bull.JobStatus[], 0, start + count, asc) results = results.concat(jobs) } @@ -188,7 +188,8 @@ class JobQueue { return results.slice(start, start + count) } - async count (state: JobState, jobType?: JobType): Promise { + async count (state: JobState | JobState[], jobType?: JobType): Promise { + const states = Array.isArray(state) ? state : [ state ] let total = 0 const filteredJobTypes = this.filterJobTypes(jobType) @@ -202,7 +203,9 @@ class JobQueue { const counts = await queue.getJobCounts() - total += counts[state] + for (const s of states) { + total += counts[s] + } } return total -- cgit v1.2.3