diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index dd8fb7af..b1911fe7 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -3133,10 +3133,22 @@ exports.motorAction = async (req, reply) => { try { - + const motorData = await MotorData.findOne({ + customerId, + motor_id: motorId, + start_instance_id: dynamicInstanceId + }); + + let totalWaterPumped = 0; // Default value in case data is missing + if (motorData && motorData.quantity_delivered) { + totalWaterPumped = motorData.quantity_delivered; + } + + console.log("quantity_delivered:", totalWaterPumped); + - const totalWaterPumped = await motorData.quantity_delivered - console.log("quantity_delivered",totalWaterPumped) + //const totalWaterPumped = await motorData.quantity_delivered + // console.log("quantity_delivered",totalWaterPumped) eventEmitter.emit("motorStop", customerId, fcmToken, tankName, blockName, stopTime, "Mobile APP", totalWaterPumped, typeOfWater, motorId, loggedInUser.phone,);