From d7fae9bfc547e78e344f49442c3d39c7bd698400 Mon Sep 17 00:00:00 2001 From: Varun Date: Fri, 21 Mar 2025 15:03:00 +0530 Subject: [PATCH] chanegs in stop --- src/controllers/tanksController.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 493a5f15..079a9fe8 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -3059,7 +3059,7 @@ exports.motorAction = async (req, reply) => { console.log(motorData,"motorData") if (motorData) { console.log("got into if") - + const receiverTank = await Tank.findOne({ customerId, tankName: motorData.receiverTank, tankLocation: motorData.receiver_type.toLowerCase() }); const receiverFinalWaterLevel = parseInt(receiverTank.waterlevel, 10); console.log(receiverFinalWaterLevel,"receiverFinalWaterLevel") @@ -3242,8 +3242,11 @@ async function stopMotor(motorId, customerId, start_instance_id) { const motorData = await MotorData.findOne({ customerId, motor_id: motorId, start_instance_id }); if (motorData) { - const startTime = moment(motorData.startTime, 'DD-MMM-YYYY - HH:mm'); - const runtime = moment.duration(moment(currentTime, 'DD-MMM-YYYY - HH:mm').diff(startTime)).asSeconds(); + const start = moment(motorData.startTime, 'DD-MMM-YYYY - HH:mm'); + const stop = moment(currentTime, 'DD-MMM-YYYY - HH:mm'); + const duration = moment.duration(stop.diff(start)); + const runtime = Math.floor(duration.asMinutes()); // runtime in minutes + const receiverTank = await Tank.findOne({ customerId, tankName: motorData.receiverTank, tankLocation: motorData.receiver_type.toLowerCase() }); const receiverFinalWaterLevel = parseInt(receiverTank.waterlevel.replace(/,/g, ''), 10);