Skip to content

Commit

Permalink
Load in the "older" specs from the older tags under the domain itself.
Browse files Browse the repository at this point in the history
  • Loading branch information
tecimovic committed Feb 23, 2021
1 parent 0f468b9 commit 8eb542d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src-electron/db/query-zcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,24 @@ async function insertDomains(db, packageId, data) {
* @returns Promise of insertion.
*/
async function insertSpecs(db, packageId, data) {
let olders = []
data.forEach((domain) => {
if ('older' in domain) {
domain.older.forEach((older) => olders.push(older))
}
})
if (olders.length > 0) {
await dbApi.dbMultiInsert(
db,
'INSERT INTO SPEC (PACKAGE_REF, CODE, DESCRIPTION, CERTIFIABLE) VALUES (?, ?, ?, ?)',
olders.map((older) => [
packageId,
older.specCode,
older.specDescription,
older.specCertifiable ? 1 : 0,
])
)
}
return dbApi.dbMultiInsert(
db,
'INSERT INTO SPEC (PACKAGE_REF, CODE, DESCRIPTION, CERTIFIABLE) VALUES (?, ?, ?, ?)',
Expand Down
2 changes: 1 addition & 1 deletion test/zcl-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ test('test Silabs zcl data loading in memory', () => {
.then(() => queryGeneric.selectCountFrom(db, 'GLOBAL_ATTRIBUTE_DEFAULT'))
.then((x) => expect(x).toEqual(126))
.then(() => queryGeneric.selectCountFrom(db, 'SPEC'))
.then((x) => expect(x).toEqual(22))
.then((x) => expect(x).toEqual(38))
.then(() =>
dbApi.dbAll(
db,
Expand Down

0 comments on commit 8eb542d

Please sign in to comment.