From 30f51589cb2841164e08badb84d0403f47002cee Mon Sep 17 00:00:00 2001 From: Scott Bender Date: Thu, 10 Dec 2020 11:27:13 -0500 Subject: [PATCH 1/2] fix: meta data for paths without a value do not get in the full tree --- src/fullsignalk.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/fullsignalk.js b/src/fullsignalk.js index 1541e1a8..2fc966e4 100644 --- a/src/fullsignalk.js +++ b/src/fullsignalk.js @@ -278,6 +278,21 @@ function addMeta(context, contextPath, source, timestamp, pathValue) { return; } signalkSchema.addMetaData(contextPath, pathValue.path, pathValue.value) + + const splitPath = pathValue.path.split('.'); + const valueLeaf = splitPath.reduce(function(previous, pathPart, i) { + if (!previous[pathPart]) { + previous[pathPart] = {}; + } + if ( i === splitPath.length-1 && typeof previous[pathPart].meta === 'undefined' ) { + let meta = signalkSchema.internalGetMetadata(contextPath + '.' + pathValue.path) + if (meta) { + _.assign(meta, previous[pathPart].meta) + previous[pathPart].meta = meta + } + } + return previous[pathPart]; + }, context); } From 4d2ab9ef7e0aa2429cb087a7808dc84481df7091 Mon Sep 17 00:00:00 2001 From: Scott Bender Date: Thu, 10 Dec 2020 11:29:24 -0500 Subject: [PATCH 2/2] fix: no need to _.assign meta data --- src/fullsignalk.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fullsignalk.js b/src/fullsignalk.js index 2fc966e4..d5144d55 100644 --- a/src/fullsignalk.js +++ b/src/fullsignalk.js @@ -287,7 +287,6 @@ function addMeta(context, contextPath, source, timestamp, pathValue) { if ( i === splitPath.length-1 && typeof previous[pathPart].meta === 'undefined' ) { let meta = signalkSchema.internalGetMetadata(contextPath + '.' + pathValue.path) if (meta) { - _.assign(meta, previous[pathPart].meta) previous[pathPart].meta = meta } }