When jobs are added to a queue, they will be in different statuses during their lifetime. BullMQ provides methods to retrieve information and jobs from the different statuses.
Job Counts
It is often necessary to know how many jobs are in a given status:
import { Queue } from'bullmq';constmyQueue=newQueue('Paint');constcounts=awaitmyQueue.getJobCounts('wait','completed','failed');// Returns an object like this { wait: number, completed: number, failed: number }
from bullmq import QueuemyQueue =Queue('Paint')counts =await myQueue.getJobCounts('wait', 'completed', 'failed')# Returns an object like this { wait: number, completed: number, failed: number }
The available status are:
completed,
failed,
delayed,
active,
wait,
waiting-children,
prioritized,
paused, and
repeat.
Get Jobs
It is also possible to retrieve the jobs with pagination style semantics. For example:
constcompleted=awaitmyQueue.getJobs(['completed'],0,100,true);// returns the oldest 100 jobs
completed =await myQueue.getJobs(['completed'], 0, 100, True)# returns the oldest 100 jobs