JobQueue was not deleting jobs correctly due to incorrect lookup in monitor object
This commit is contained in:
1 parent
2a79264a9a
commit
9e51cffb67
2 files changed
+3
-2
No files matched your search
@@ -233,9 +233,10 @@ const editMonitor = async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const jobBeforeEdit = await req.db.getMonitorById(req, res);
|
||||||
const editedMonitor = await req.db.editMonitor(req, res);
|
const editedMonitor = await req.db.editMonitor(req, res);
|
||||||
// Delete the old job(editedMonitor has the same ID as the old monitor)
|
// Delete the old job(editedMonitor has the same ID as the old monitor)
|
||||||
await req.jobQueue.deleteJob(editedMonitor);
|
await req.jobQueue.deleteJob(jobBeforeEdit);
|
||||||
// Add the new job back to the queue
|
// Add the new job back to the queue
|
||||||
await req.jobQueue.addJob(editedMonitor._id, editedMonitor);
|
await req.jobQueue.addJob(editedMonitor._id, editedMonitor);
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ class JobQueue {
|
|||||||
*/
|
*/
|
||||||
async deleteJob(monitor) {
|
async deleteJob(monitor) {
|
||||||
try {
|
try {
|
||||||
const deleted = await this.queue.removeRepeatable(monitor.id, {
|
const deleted = await this.queue.removeRepeatable(monitor._id, {
|
||||||
every: monitor.interval,
|
every: monitor.interval,
|
||||||
});
|
});
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
|
|||||||
Reference in new issue
Block a user