From df1ab37ac51af342ffbadff8aeba2b18313a2dbb Mon Sep 17 00:00:00 2001 From: Rogger Valverde Date: Fri, 27 Oct 2023 21:49:40 -0700 Subject: [PATCH] feat(bullmq): support removing repeatable jobs (#667) --- example/bullmq.js | 1 + src/server/views/api/repeatableJobRemove.js | 8 +++++--- src/server/views/dashboard/queueJobsByState.js | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/example/bullmq.js b/example/bullmq.js index f1a2932d..3fe490bf 100644 --- a/example/bullmq.js +++ b/example/bullmq.js @@ -69,6 +69,7 @@ async function main() { // adding delayed jobs const delayedJob = await queue.add('delayed', {}, {delay: 60 * 1000}); + await queue.add('cron', {}, {repeat: {pattern: '* 1 * 1 *'}}); delayedJob.log('Log message'); Arena( diff --git a/src/server/views/api/repeatableJobRemove.js b/src/server/views/api/repeatableJobRemove.js index 6e8c4503..88b48f3a 100644 --- a/src/server/views/api/repeatableJobRemove.js +++ b/src/server/views/api/repeatableJobRemove.js @@ -9,10 +9,12 @@ async function handler(req, res) { if (!job) return res.status(404).send({error: 'job not found'}); try { - if (job.opts.repeat.key) { - await queue.removeRepeatableByKey(job.opts.repeat.key); + if (job.opts.repeat.key || job.repeatJobKey) { + await queue.removeRepeatableByKey( + job.opts.repeat.key || job.repeatJobKey + ); } else { - await queue.removeRepeatable(job.name, job.opts.repeat); + await queue.removeRepeatable(job.name, job.opts.repeat, job.opts.jobId); } return res.sendStatus(200); } catch (e) { diff --git a/src/server/views/dashboard/queueJobsByState.js b/src/server/views/dashboard/queueJobsByState.js index 3f531675..c9272724 100644 --- a/src/server/views/dashboard/queueJobsByState.js +++ b/src/server/views/dashboard/queueJobsByState.js @@ -138,7 +138,7 @@ async function _html(req, res) { jobs[i].showRetryButton = !queue.IS_BEE || jobState === 'failed'; jobs[i].retryButtonText = jobState === 'failed' ? 'Retry' : 'Trigger'; jobs[i].showPromoteButton = !queue.IS_BEE && jobState === 'delayed'; - jobs[i].showDeleteRepeatableButton = queue.IS_BULL && jobs[i].opts.repeat; + jobs[i].showDeleteRepeatableButton = !queue.IS_BEE && jobs[i].opts.repeat; jobs[i].parent = JobHelpers.getKeyProperties(jobs[i].parentKey); } }