From f4c6286940eab285129590dbbd4595242476612c Mon Sep 17 00:00:00 2001 From: varun Date: Thu, 16 May 2024 02:48:56 -0400 Subject: [PATCH] added start and stop time --- src/controllers/tanksController.js | 4 ++-- src/routes/tanksRoute.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index be6c63cd..7a9a19b9 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -883,7 +883,7 @@ exports.motorAction = async (req, reply) => { if (action === "stop") { await Tank.updateOne( { customerId, "connections.inputConnections.motor_id": motorId }, - { $set: { "connections.inputConnections.$.motor_stop_status": "1" } } + { $set: { "connections.inputConnections.$.motor_stop_status": "1",stopTime:req.body.stopTime } } ); } else { // Update the motor stop status to "2" for start action @@ -917,7 +917,7 @@ exports.motorAction = async (req, reply) => { }, 60000); // Check water level every minute } else if (req.body.threshold_type === "litres") { // If threshold type is percentage, calculate percentage threshold - const receiver_tank_info = await Tank.findOne({ customerId, tankName: req.body.to, tankLocation: req.body.to_type.toLowerCase() }); + const receiver_tank_info = await Tank.findOne({ customerId, tankName: req.body.to, tankLocation: req.body.to_type.toLowerCase(),startTime:req.body.startTime }); if (!receiver_tank_info) { throw new Error("Receiver tank not found."); } diff --git a/src/routes/tanksRoute.js b/src/routes/tanksRoute.js index b21a9539..1edcbcb3 100644 --- a/src/routes/tanksRoute.js +++ b/src/routes/tanksRoute.js @@ -289,7 +289,7 @@ module.exports = function (fastify, opts, next) { threshold_type:{type:"string"}, manual_threshold_litres:{type:"string"}, manual_threshold_time:{type:"string"}, - stop_at:{type:"number"}, + stopTime:{type:"string"}, motor_id:{type:"string"}, }, },