dt-common-device 10.0.0 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -212,36 +212,38 @@ let AdminRepository = (() => {
|
|
|
212
212
|
return collectionZoneDevices;
|
|
213
213
|
}
|
|
214
214
|
async getZonesByAccessGroups(accessGroupIds) {
|
|
215
|
-
// Fetch
|
|
215
|
+
// Fetch zone IDs associated with these access groups
|
|
216
216
|
const zonesIdsQuery = `
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
SELECT DISTINCT z."zoneId"
|
|
218
|
+
FROM dt_zones_collection_map z
|
|
219
|
+
WHERE z."collectionId" = ANY($1)
|
|
220
|
+
`;
|
|
221
221
|
const zonesIdsResult = await this.postgres.query(zonesIdsQuery, [
|
|
222
222
|
accessGroupIds,
|
|
223
223
|
]);
|
|
224
|
+
const zonesIds = zonesIdsResult.rows.map((row) => row.zoneId);
|
|
225
|
+
if (zonesIds.length === 0) {
|
|
226
|
+
return [];
|
|
227
|
+
}
|
|
228
|
+
// Fetch zone type IDs for guest rooms and rooms
|
|
224
229
|
const zoneTypesQuery = `
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
230
|
+
SELECT id
|
|
231
|
+
FROM "dt_zoneTypes"
|
|
232
|
+
WHERE name IN ('Guest Room', 'Room')
|
|
233
|
+
`;
|
|
229
234
|
const zoneTypes = await this.postgres.query(zoneTypesQuery);
|
|
230
|
-
const
|
|
231
|
-
|
|
235
|
+
const guestRoomZoneTypeIds = zoneTypes.rows.map((e) => e.id);
|
|
236
|
+
// Fetch zones matching both sets of IDs
|
|
232
237
|
const zonesQuery = `
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
238
|
+
SELECT id
|
|
239
|
+
FROM dt_zones
|
|
240
|
+
WHERE id = ANY($1) AND "zoneTypeId" = ANY($2)
|
|
241
|
+
`;
|
|
237
242
|
const zonesResult = await this.postgres.query(zonesQuery, [
|
|
238
243
|
zonesIds,
|
|
239
|
-
|
|
244
|
+
guestRoomZoneTypeIds,
|
|
240
245
|
]);
|
|
241
|
-
|
|
242
|
-
return zonesResult?.rows?.map((e) => e.id);
|
|
243
|
-
}
|
|
244
|
-
return [];
|
|
246
|
+
return zonesResult.rows.map((e) => e.id);
|
|
245
247
|
}
|
|
246
248
|
async getAccessGroup(accessGroupId) {
|
|
247
249
|
const query = `
|