support tem member fetch the building deatils

master^2
Bhaskar 5 months ago
parent a0e05ce743
commit b2782cdae3

@ -4570,19 +4570,24 @@ exports.getDisconnectedCustomerDetailsByTeamMemberId = async (req, reply) => {
} }
// 2. Extract all hardwareIds from issues // 2. Extract all hardwareIds from issues
const hardwareIds = []; // 2. Extract all hardwareIds and masterHardwareIds from issues
for (const issue of supportRecord.issues || []) { const hardwareIds = [];
for (const issue of supportRecord.issues || []) {
if (issue.hardwareId) hardwareIds.push(issue.hardwareId); if (issue.hardwareId) hardwareIds.push(issue.hardwareId);
if (Array.isArray(issue.hardwareIds)) hardwareIds.push(...issue.hardwareIds); if (Array.isArray(issue.hardwareIds)) hardwareIds.push(...issue.hardwareIds);
} if (issue.masterHardwareId) hardwareIds.push(issue.masterHardwareId); // Add this line
}
if (hardwareIds.length === 0) { if (hardwareIds.length === 0) {
return reply.code(404).send({ message: "No hardware IDs found in issues" }); return reply.code(404).send({ message: "No hardware IDs found in issues" });
} }
console.log("hardwareIds",hardwareIds)
// 3. Find disconnected Insensors matching connected_to // 3. Find disconnected Insensors matching connected_to
const uniqueHardwareIds = [...new Set(hardwareIds)];
const disconnectedSensors = await Insensors.find({ const disconnectedSensors = await Insensors.find({
connected_to: { $in: hardwareIds }, connected_to: { $in: uniqueHardwareIds },
connected_status: "disconnected" connected_status: "disconnected"
}).lean(); }).lean();

Loading…
Cancel
Save