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
const response = {
status_code: 200, status_code: 200,
tankData, tankData,
consumptiorecordsdatewise: tankconsumptionData, consumptiorecordsdatewise: tankconsumptionData,
totalConsumptionPercentage, totalConsumptionPercentage,
...(typeofwater === "all" totalConsumptionPercentageForBore: typeofwater !== "drinking" ? boreConsumptionPercentage : 0,
? { totalConsumptionPercentageForDrinking: typeofwater !== "bore" ? drinkingConsumptionPercentage : 0,
totalConsumptionPercentageForBore: boreConsumptionPercentage, totalConsumptionForBore: typeofwater !== "drinking" ? totalBoreConsumptionForSelectedBlockAndTypeOfWater : 0,
totalConsumptionPercentageForDrinking: drinkingConsumptionPercentage, totalConsumptionForDrinking: typeofwater !== "bore" ? totalDrinkingConsumptionForSelectedBlockAndTypeOfWater : 0,
totalConsumptionForBore: totalBoreConsumptionForSelectedBlockAndTypeOfWater,
totalConsumptionForDrinking: totalDrinkingConsumptionForSelectedBlockAndTypeOfWater,
}
: {
[`total consumption of ${typeofwater} and selected block`]:
typeofwater === "bore"
? totalBoreConsumptionForSelectedBlockAndTypeOfWater
: totalDrinkingConsumptionForSelectedBlockAndTypeOfWater,
}
),
[`total consumption of ${typeofwater} and selected block`]: totalConsumptionForSelectedBlockAndTypeOfWater [`total consumption of ${typeofwater} and selected block`]: totalConsumptionForSelectedBlockAndTypeOfWater
}; };
// Send the response
reply.send(response); reply.send(response);
} catch (err) { } catch (err) {

Loading…
Cancel
Save