Skip to content

Commit

Permalink
feat(bullmq): support removing repeatable jobs (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored Oct 28, 2023
1 parent 97164ed commit df1ab37
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions example/bullmq.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 5 additions & 3 deletions src/server/views/api/repeatableJobRemove.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/dashboard/queueJobsByState.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit df1ab37

Please sign in to comment.