From 24fb9eba5fe9616c1121c21915b19f9637fe50ca Mon Sep 17 00:00:00 2001 From: Evgeni Margolis Date: Fri, 3 Feb 2023 09:45:37 -0800 Subject: [PATCH] Updated selectEndpointClusterEvents() function to use existing mapping method dbMapping.map.event --- src-electron/db/query-endpoint.js | 15 ++------------- src-electron/util/zcl-util.js | 4 ++-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src-electron/db/query-endpoint.js b/src-electron/db/query-endpoint.js index b3e7a15a74..094c630f5c 100644 --- a/src-electron/db/query-endpoint.js +++ b/src-electron/db/query-endpoint.js @@ -274,7 +274,7 @@ ORDER BY C.CODE * @returns promise that resolves into endpoint cluster events */ async function selectEndpointClusterEvents(db, clusterId, endpointTypeId) { - let rows = await dbApi.dbAll( + return dbApi.dbAll( db, ` SELECT @@ -296,18 +296,7 @@ ORDER BY E.MANUFACTURER_CODE, E.CODE `, [clusterId, endpointTypeId] ) - - return rows.map((row) => { - return { - id: row['EVENT_ID'], - name: row['NAME'], - code: row['CODE'], - clusterId: clusterId, - manufacturerCode: row['MANUFACTURER_CODE'], - isOptional: dbApi.fromDbBool(row['IS_OPTIONAL']), - hexCode: '0x' + bin.int16ToHex(row['CODE']), - } - }) + .then((rows) => rows.map(dbMapping.map.event)) } /** diff --git a/src-electron/util/zcl-util.js b/src-electron/util/zcl-util.js index 718ff77351..64b38c70f7 100644 --- a/src-electron/util/zcl-util.js +++ b/src-electron/util/zcl-util.js @@ -86,8 +86,8 @@ function eventComparator(a, b) { if (a.manufacturerCode < b.manufacturerCode) return -1 if (a.manufacturerCode > b.manufacturerCode) return 1 - if (a.hexCode < b.hexCode) return -1 - if (a.hexCode > b.hexCode) return 1 + if (a.code < b.code) return -1 + if (a.code > b.code) return 1 return 0 }