diff --git a/public/dashboard.js b/public/dashboard.js index 03596c7c..c5ff93da 100644 --- a/public/dashboard.js +++ b/public/dashboard.js @@ -110,6 +110,7 @@ $(document).ready(() => { queueName, action, jobs: [], + queueState, }; $bulkActionContainer.each((index, value) => { diff --git a/src/server/views/api/bulkAction.js b/src/server/views/api/bulkAction.js index 1b3fdc1a..5c0d27b9 100644 --- a/src/server/views/api/bulkAction.js +++ b/src/server/views/api/bulkAction.js @@ -16,7 +16,7 @@ function bulkAction(action) { const queue = await Queues.get(queueName, queueHost); if (!queue) return res.status(404).send({ error: 'queue not found' }); - const { jobs } = req.body; + const { jobs, queueState } = req.body; try { if (!_.isEmpty(jobs)) { @@ -24,7 +24,13 @@ function bulkAction(action) { const fetchedJobs = await Promise.all(jobsPromises); const actionPromises = action === 'retry' - ? fetchedJobs.map((job) => Queues.set(queue, job.data, job.name)) + ? fetchedJobs.map((job) => { + if (queueState === 'failed' && typeof job.retry === 'function') { + return job.retry(); + } else { + return Queues.set(queue, job.data, job.name); + } + }) : fetchedJobs.map((job) => job[action]()); await Promise.all(actionPromises); return res.sendStatus(200);