Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
54 lines
1.3 KiB
Plaintext
54 lines
1.3 KiB
Plaintext
/**
|
|
* Gets all queued jobs that can be run. This means they either:
|
|
* - failed but do not have a definitive error => can be retried
|
|
* - are currently processing
|
|
* - have not been started yet
|
|
*/ export async function countRunnableOrActiveJobsForQueue({ onlyScheduled = false, queue, req, taskSlug, workflowSlug }) {
|
|
const and = [
|
|
{
|
|
queue: {
|
|
equals: queue
|
|
}
|
|
},
|
|
{
|
|
completedAt: {
|
|
exists: false
|
|
}
|
|
},
|
|
{
|
|
error: {
|
|
exists: false
|
|
}
|
|
}
|
|
];
|
|
if (taskSlug) {
|
|
and.push({
|
|
taskSlug: {
|
|
equals: taskSlug
|
|
}
|
|
});
|
|
} else if (workflowSlug) {
|
|
and.push({
|
|
workflowSlug: {
|
|
equals: workflowSlug
|
|
}
|
|
});
|
|
}
|
|
if (onlyScheduled) {
|
|
and.push({
|
|
'meta.scheduled': {
|
|
equals: true
|
|
}
|
|
});
|
|
}
|
|
const runnableOrActiveJobsForQueue = await req.payload.db.count({
|
|
collection: 'payload-jobs',
|
|
req,
|
|
where: {
|
|
and
|
|
}
|
|
});
|
|
return runnableOrActiveJobsForQueue.totalDocs;
|
|
}
|
|
|
|
//# sourceMappingURL=countRunnableOrActiveJobsForQueue.js.map |