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 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();

Loading…
Cancel
Save