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 zones associated with these access groups
215
+ // Fetch zone IDs associated with these access groups
216
216
  const zonesIdsQuery = `
217
- SELECT DISTINCT z."zoneId"
218
- FROM dt_zones_collection_map z
219
- WHERE z."collectionId" = ANY($1)
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
- SELECT id
226
- FROM "dt_zoneTypes"
227
- WHERE name = 'Guest Room'
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 guestRoomZoneTypeId = zoneTypes.rows[0].id;
231
- const zonesIds = zonesIdsResult.rows.map((row) => row.zoneId);
235
+ const guestRoomZoneTypeIds = zoneTypes.rows.map((e) => e.id);
236
+ // Fetch zones matching both sets of IDs
232
237
  const zonesQuery = `
233
- SELECT id
234
- FROM dt_zones
235
- WHERE id = ANY($1) AND "zoneTypeId" = $2
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
- guestRoomZoneTypeId,
244
+ guestRoomZoneTypeIds,
240
245
  ]);
241
- if (zonesResult?.rows?.length > 0) {
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 = `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "10.0.0",
3
+ "version": "10.0.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [