Skip to content

Commit

Permalink
cleanup and properly retrieve device ref
Browse files Browse the repository at this point in the history
  • Loading branch information
paulr34 committed Aug 26, 2024
1 parent ebe0035 commit e0fe546
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src-electron/db/query-endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ ORDER BY E1.ENDPOINT_IDENTIFIER
* @returns {Promise<Array>} - A promise that resolves to an array of rows containing DEVICE_TYPE_REF.
*/
async function getRootNode(db, packageIds) {
console.log(packageIds)
const query = `
SELECT DEVICE_TYPE_REF
FROM ENDPOINT_COMPOSITION
Expand All @@ -77,7 +78,7 @@ async function getRootNode(db, packageIds) {
dbEnum.composition.rootNode,
...packageIds
])
return result.rows
return result.DEVICE_TYPE_REF
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src-electron/rest/endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,14 @@ function httpPostEndpointType(db) {
function httpGetRootNode(db) {
return async (request, response) => {
let sessionId = request.zapSessionId
let packageIds = await queryPackage.getSessionZclPackageIds(db, sessionId)
console.log(sessionId)
let packages = await queryPackage.getPackageSessionPackagePairBySessionId(
db,
sessionId
)
let packageIds = packages.map((item) => item.pkg.id)
let rootNode = await queryEndpoint.getRootNode(db, packageIds)
response.status(StatusCodes.OK).json(rootNode)
response.status(StatusCodes.OK).json({ rootNode: rootNode })
}
}

Expand Down

0 comments on commit e0fe546

Please sign in to comment.