typeOfwater added in fetch issues by category

master^2
Bhaskar 4 months ago
parent c5ab234dd7
commit ba3510dc3a

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

Loading…
Cancel
Save