+ // TODO: optimize
+ for (const jobType of jobTypes) {
+ const queue = this.queues[ jobType ]
+ if (queue === undefined) {
+ logger.error('Unknown queue %s to list jobs.', jobType)
+ continue
+ }
+
+ // FIXME: Bull queue typings does not have getJobs method
+ const jobs = await (queue as any).getJobs(state, 0, start + count, asc)
+ results = results.concat(jobs)
+ }
+
+ results.sort((j1: any, j2: any) => {
+ if (j1.timestamp < j2.timestamp) return -1
+ else if (j1.timestamp === j2.timestamp) return 0
+
+ return 1