From b2782cdae3e8bf414e9fecbd0d4582957152ca75 Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Thu, 22 May 2025 15:38:42 +0530 Subject: [PATCH] support tem member fetch the building deatils --- src/controllers/installationController.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/controllers/installationController.js b/src/controllers/installationController.js index b84e70b3..2c318b9f 100644 --- a/src/controllers/installationController.js +++ b/src/controllers/installationController.js @@ -4570,19 +4570,24 @@ exports.getDisconnectedCustomerDetailsByTeamMemberId = async (req, reply) => { } // 2. Extract all hardwareIds from issues - const hardwareIds = []; - for (const issue of supportRecord.issues || []) { - if (issue.hardwareId) hardwareIds.push(issue.hardwareId); - if (Array.isArray(issue.hardwareIds)) hardwareIds.push(...issue.hardwareIds); - } + // 2. Extract all hardwareIds and masterHardwareIds from issues +const hardwareIds = []; +for (const issue of supportRecord.issues || []) { + if (issue.hardwareId) hardwareIds.push(issue.hardwareId); + if (Array.isArray(issue.hardwareIds)) hardwareIds.push(...issue.hardwareIds); + if (issue.masterHardwareId) hardwareIds.push(issue.masterHardwareId); // Add this line +} + if (hardwareIds.length === 0) { return reply.code(404).send({ message: "No hardware IDs found in issues" }); } - + console.log("hardwareIds",hardwareIds) // 3. Find disconnected Insensors matching connected_to + const uniqueHardwareIds = [...new Set(hardwareIds)]; + const disconnectedSensors = await Insensors.find({ - connected_to: { $in: hardwareIds }, + connected_to: { $in: uniqueHardwareIds }, connected_status: "disconnected" }).lean();