Skip to content

Commit

Permalink
Updated selectEndpointClusterEvents() function to use existing mappin…
Browse files Browse the repository at this point in the history
…g method dbMapping.map.event
  • Loading branch information
emargolis committed Feb 3, 2023
1 parent 166c2a0 commit 24fb9eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
15 changes: 2 additions & 13 deletions src-electron/db/query-endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src-electron/util/zcl-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 24fb9eb

Please sign in to comment.