master^2
Varun 8 months ago
parent a7488d4236
commit edeae05743

@ -1077,6 +1077,7 @@ exports.consumption = async (request, reply) => {
const tanks = await Tank.find(tankQuery); const tanks = await Tank.find(tankQuery);
const tankData = []; const tankData = [];
const tankconsumptionData = []; const tankconsumptionData = [];
let totalConsumptionForSelectedBlockAndTypeOfWater = 0;
let totalBoreConsumptionForSelectedBlockAndTypeOfWater = 0; let totalBoreConsumptionForSelectedBlockAndTypeOfWater = 0;
let totalBoreCapacityForSelectedBlockAndTypeOfWater = 0; let totalBoreCapacityForSelectedBlockAndTypeOfWater = 0;
let totalDrinkingConsumptionForSelectedBlockAndTypeOfWater = 0; let totalDrinkingConsumptionForSelectedBlockAndTypeOfWater = 0;
@ -1108,6 +1109,7 @@ exports.consumption = async (request, reply) => {
}, 0); }, 0);
const consumption = (waterlevel_at_midnight + total_water_added_from_midnight) - waterlevel + total_consumption_from_records; const consumption = (waterlevel_at_midnight + total_water_added_from_midnight) - waterlevel + total_consumption_from_records;
totalConsumptionForSelectedBlockAndTypeOfWater += consumption;
// Add to the total consumption and capacities based on water type // Add to the total consumption and capacities based on water type
if (tank.typeOfWater === "bore" || tank.typeOfWater === "Bore Water") { if (tank.typeOfWater === "bore" || tank.typeOfWater === "Bore Water") {
@ -1171,7 +1173,9 @@ exports.consumption = async (request, reply) => {
typeofwater === "bore" typeofwater === "bore"
? totalBoreConsumptionForSelectedBlockAndTypeOfWater ? totalBoreConsumptionForSelectedBlockAndTypeOfWater
: totalDrinkingConsumptionForSelectedBlockAndTypeOfWater, : totalDrinkingConsumptionForSelectedBlockAndTypeOfWater,
}), }
),
[`total consumption of ${typeofwater} and selected block`]: totalConsumptionForSelectedBlockAndTypeOfWater
}; };
reply.send(response); reply.send(response);

Loading…
Cancel
Save