master
varun 1 year ago
parent eca056dc71
commit db95ed23c5

@ -169,12 +169,13 @@ exports.deleteTanksInfo = async (req, reply) => {
}
};
exports.getConnectionsInfoOfParticularTank = async (req, reply) => {
try {
const customerId = req.params.customerId;
const tankName = req.body.tankName;
const tankLocation = req.body.tankLocation.toLowerCase();
console.log(customerId,tankName,tankLocation)
console.log(customerId, tankName, tankLocation);
// Find the specific tank
const mainTank = await Tank.findOne({
@ -204,14 +205,22 @@ exports.getConnectionsInfoOfParticularTank = async (req, reply) => {
const inputTanks = await Promise.all(inputTankPromises);
const outputTanks = await Promise.all(outputTankPromises);
// Combine data from the main tank and its connections
const result = {
mainTank: mainTank,
inputConnections: inputTanks.filter(tank => tank !== null), // Filter out null results
outputConnections: outputTanks.filter(tank => tank !== null) // Filter out null results
};
reply.send({ status_code: 200, data: result });
// Combine data from the main tank and its connections in a list with descriptive messages
const resultList = [{
type: 'Main Tank',
message: 'This is the data of the main tank.',
details: mainTank
}, {
type: 'Input Connections',
message: 'These are the data of all input tanks connected to the main tank.',
details: inputTanks.filter(tank => tank !== null) // Filter out null results
}, {
type: 'Output Connections',
message: 'These are the data of all output tanks connected to the main tank.',
details: outputTanks.filter(tank => tank !== null) // Filter out null results
}];
reply.send({ status_code: 200, data: resultList });
} catch (err) {
throw boom.boomify(err);
}

Loading…
Cancel
Save