1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

add display of logs matching any state

This commit is contained in:
Rigel Kent 2020-12-13 19:27:25 +01:00
parent 7aebd32f83
commit 040d6896a3
No known key found for this signature in database
GPG key ID: 5E53E96A494E452F
8 changed files with 113 additions and 26 deletions

View file

@ -154,13 +154,13 @@ class JobQueue {
}
async listForApi (options: {
state: JobState
state: JobState | JobState[]
start: number
count: number
asc?: boolean
jobType: JobType
}): Promise<Bull.Job[]> {
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<number> {
async count (state: JobState | JobState[], jobType?: JobType): Promise<number> {
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