From 6ca372fed0730cb595a3caa371922873ded7f774 Mon Sep 17 00:00:00 2001 From: varun Date: Tue, 14 May 2024 06:29:04 -0400 Subject: [PATCH] changes in connections --- src/controllers/createConnectionController.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/controllers/createConnectionController.js b/src/controllers/createConnectionController.js index ad69cbd0..231d5cc6 100644 --- a/src/controllers/createConnectionController.js +++ b/src/controllers/createConnectionController.js @@ -510,11 +510,7 @@ exports.createConnections = async (req, body) => { try { const customerId = req.params.customerId; const tankname = req.body.tankname; - const water_capacity = req.body.capacity; - const water_water_level = req.body.water_level - const motorId = req.body.motor_id - const motorStatus = req.body.motor_status - const motorStopStatus = req.body.motor_stop_status + const tankInfo = await Tank.findOne({ customerId: customerId.toString(), tankName: tankname }); const usertobeInserted = req.body; tankInfo.connections.source = tankInfo.tankName; @@ -564,6 +560,7 @@ exports.createConnections = async (req, body) => { if (sump_names.includes(tankname)) { console.log(`${tankname} exists in ${sump_names}`); } else { + const tank_info1 = await Tank.findOne({ customerId: customerId.toString(), tankName: tankname }); const tankConnections = await Tank.findOneAndUpdate( { customerId: customerId.toString(), tankName: tankName }, { @@ -574,10 +571,10 @@ exports.createConnections = async (req, body) => { input_type: 'sump', inputismotor: true || false, motor_id: motorId || null, - water_level: water_water_level || null, - capacity: water_capacity || null, - motor_status: motorStatus || "0", - motor_stop_status: motorStopStatus || "1" + water_level: tank_info1.waterlevel || null, + capacity: tank_info1.capacity || null, + motor_status: data.motor_status || "1", + motor_stop_status: data.motor_stop_status || "1" }], }, },