aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/job-queue.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/job-queue/job-queue.ts')
-rw-r--r--server/lib/job-queue/job-queue.ts13
1 files changed, 8 insertions, 5 deletions
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 {
154 } 154 }
155 155
156 async listForApi (options: { 156 async listForApi (options: {
157 state: JobState 157 state: JobState | JobState[]
158 start: number 158 start: number
159 count: number 159 count: number
160 asc?: boolean 160 asc?: boolean
161 jobType: JobType 161 jobType: JobType
162 }): Promise<Bull.Job[]> { 162 }): Promise<Bull.Job[]> {
163 const { state, start, count, asc, jobType } = options 163 const { state = Array.isArray(options.state) ? options.state : [ options.state ], start, count, asc, jobType } = options
164 let results: Bull.Job[] = [] 164 let results: Bull.Job[] = []
165 165
166 const filteredJobTypes = this.filterJobTypes(jobType) 166 const filteredJobTypes = this.filterJobTypes(jobType)
@@ -172,7 +172,7 @@ class JobQueue {
172 continue 172 continue
173 } 173 }
174 174
175 const jobs = await queue.getJobs([ state ], 0, start + count, asc) 175 const jobs = await queue.getJobs(state as Bull.JobStatus[], 0, start + count, asc)
176 results = results.concat(jobs) 176 results = results.concat(jobs)
177 } 177 }
178 178
@@ -188,7 +188,8 @@ class JobQueue {
188 return results.slice(start, start + count) 188 return results.slice(start, start + count)
189 } 189 }
190 190
191 async count (state: JobState, jobType?: JobType): Promise<number> { 191 async count (state: JobState | JobState[], jobType?: JobType): Promise<number> {
192 const states = Array.isArray(state) ? state : [ state ]
192 let total = 0 193 let total = 0
193 194
194 const filteredJobTypes = this.filterJobTypes(jobType) 195 const filteredJobTypes = this.filterJobTypes(jobType)
@@ -202,7 +203,9 @@ class JobQueue {
202 203
203 const counts = await queue.getJobCounts() 204 const counts = await queue.getJobCounts()
204 205
205 total += counts[state] 206 for (const s of states) {
207 total += counts[s]
208 }
206 } 209 }
207 210
208 return total 211 return total