taskforcesh / bullmq

BullMQ - Message Queue and Batch processing for NodeJS and Python based on Redis
https://bullmq.io
MIT License
6.21k stars 407 forks source link

Include the status of a job in the object #2427

Open BjoernRave opened 9 months ago

BjoernRave commented 9 months ago

I want to build an overview of all the jobs.

I am using this code for that:

import { queue } from "../queue/queue"

const jobs = await queue.getJobs([
      "active",
      "waiting",
      "delayed",
      "completed",
      "failed",
      "paused",
      "prioritized",
      "repeat",
      "wait",
      "waiting",
      "waiting-children",
    ])

It would be nice to add the status of the job to the objects returned by this function, currently I need to get this info by checking what values are available on the Job object

ivnnv commented 9 months ago

just a workaround you could use: you can iterate thru the different status methods (queue.getActiveJobs(), getWaitingJobs()etc ) to get the jobs grouped by status (then you can join after if needed). Anyway plain getJobs is not the best idea if you have thousands or millions of jobs because you would need to paginate if you really want to get all of them.