diff --git a/src/controllers/installationController.js b/src/controllers/installationController.js index 047afeec..7e8105f1 100644 --- a/src/controllers/installationController.js +++ b/src/controllers/installationController.js @@ -6559,8 +6559,16 @@ exports.particularCategory = async (req, reply) => { for (const master of allRelatedSensors.filter(i => i.type === "master")) { const slaves = await Insensors.find({ connected_to: master.hardwareId }).lean(); - const slaveDetails = slaves.map(slave => { - const slaveIssue = issues.find(i => i.hardwareId === slave.hardwareId); + const slaveDetails = await Promise.all(slaves.map(async (slave) => { + const slaveHardwareId = slave.tankhardwareId; + + const tankInfo = await Tank.findOne({ + $or: [ + { hardwareId: slaveHardwareId }, + { tankhardwareId: slaveHardwareId } + ] + }).lean(); + console.log("tankInfo",tankInfo) const slaveComments = (support.comments || []) .filter(comment => comment.hardwareId === slave.hardwareId) .map(c => c.text); @@ -6577,14 +6585,13 @@ exports.particularCategory = async (req, reply) => { connected_to: slave.connected_to || "", masterName: orderMap[master.hardwareId]?.masterName || "", type: "slave", - typeOfWater: slave.typeOfWater || "", + typeOfWater: tankInfo?.typeOfWater || "", support_lora_last_check_time: slave.support_lora_last_check_time || null, team_member_support_lora_last_check_time: slave.team_member_support_lora_last_check_time || null, comments: slaveComments }; - }); + })); - const masterIssue = issues.find(i => i.hardwareId === master.hardwareId); const masterComments = (support.comments || []) .filter(comment => comment.hardwareId === master.hardwareId) .map(c => c.text);