changes in response in cinsumption

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

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

Loading…
Cancel
Save