From 5d24f3136c8845d8c209d324a3afd7996d04713a Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Wed, 3 Jul 2024 13:55:44 -0700 Subject: [PATCH] Replace job in queue when monitor is edited --- Server/controllers/monitorController.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Server/controllers/monitorController.js b/Server/controllers/monitorController.js index 800ec994c..362cfec36 100644 --- a/Server/controllers/monitorController.js +++ b/Server/controllers/monitorController.js @@ -214,6 +214,10 @@ const editMonitor = async (req, res, next) => { try { const editedMonitor = await req.db.editMonitor(req, res); + // Delete the old job(editedMonitor has the same ID as the old monitor) + req.jobQueue.deleteJob(editedMonitor); + // Add the new job back to the queue + req.jobQueue.addJob(editedMonitor._id, editedMonitor); return res.status(200).json({ success: true, msg: successMessages.MONITOR_EDIT,