- count (state: JobState) {
- return new Promise<number>((res, rej) => {
- this.jobQueue[state + 'Count']((err, total) => {
- if (err) return rej(err)
+ async listForApi (options: {
+ state: JobState
+ start: number
+ count: number
+ asc?: boolean
+ jobType: JobType
+ }): Promise<Bull.Job[]> {
+ const { state, start, count, asc, jobType } = options
+ let results: Bull.Job[] = []
+
+ const filteredJobTypes = this.filterJobTypes(jobType)
+
+ for (const jobType of filteredJobTypes) {
+ const queue = this.queues[jobType]
+ if (queue === undefined) {
+ logger.error('Unknown queue %s to list jobs.', jobType)
+ continue
+ }