diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 6769e7ea..075c3034 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -3062,6 +3062,10 @@ exports.motorAction = async (req, reply) => { const quantityDelivered = receiverFinalWaterLevel - parseInt(motorData.receiverInitialwaterlevel, 10); const water_pumped_till_now = parseInt(receiverTank.total_water_added_from_midnight, 10); const totalwaterpumped = quantityDelivered + water_pumped_till_now; + 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()); await Tank.findOneAndUpdate( { customerId, tankName: motorData.receiverTank, tankLocation: motorData.receiver_type.toLowerCase() }, @@ -3074,7 +3078,8 @@ exports.motorAction = async (req, reply) => { $set: { stopTime: currentTime, receiverfinalwaterlevel: receiverFinalWaterLevel.toString(), - quantity_delivered: quantityDelivered.toString() + quantity_delivered: quantityDelivered.toString(), + runtime:runtime.toString() } } );