changes in response in cinsumption

master^2
Varun 8 months ago
parent 30bd1c5283
commit db1f524ab9

@ -1228,28 +1228,23 @@ exports.consumption = async (request, reply) => {
).toFixed(2);
// Include the total consumption in the response
// Construct the response
const response = {
status_code: 200,
tankData,
consumptiorecordsdatewise: tankconsumptionData,
totalConsumptionPercentage,
...(typeofwater === "all"
? {
totalConsumptionPercentageForBore: boreConsumptionPercentage,
totalConsumptionPercentageForDrinking: drinkingConsumptionPercentage,
totalConsumptionForBore: totalBoreConsumptionForSelectedBlockAndTypeOfWater,
totalConsumptionForDrinking: totalDrinkingConsumptionForSelectedBlockAndTypeOfWater,
}
: {
[`total consumption of ${typeofwater} and selected block`]:
typeofwater === "bore"
? totalBoreConsumptionForSelectedBlockAndTypeOfWater
: totalDrinkingConsumptionForSelectedBlockAndTypeOfWater,
}
),
totalConsumptionPercentageForBore: typeofwater !== "drinking" ? boreConsumptionPercentage : 0,
totalConsumptionPercentageForDrinking: typeofwater !== "bore" ? drinkingConsumptionPercentage : 0,
totalConsumptionForBore: typeofwater !== "drinking" ? totalBoreConsumptionForSelectedBlockAndTypeOfWater : 0,
totalConsumptionForDrinking: typeofwater !== "bore" ? totalDrinkingConsumptionForSelectedBlockAndTypeOfWater : 0,
[`total consumption of ${typeofwater} and selected block`]: totalConsumptionForSelectedBlockAndTypeOfWater
};
// Send the response
reply.send(response);
} catch (err) {
throw boom.boomify(err);

Loading…
Cancel
Save