-
Notifications
You must be signed in to change notification settings - Fork 0
/
konfigBuilder.js
30 lines (28 loc) · 1015 Bytes
/
konfigBuilder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"use strict";
var _ = require('underscore');
function invertMeasurements(component) {
var measurements = [];
_.forEach(_.keys(component.measurements), function (measurementName) {
if (!_.isEmpty(component.measurements[measurementName].file)) {
measurements.push(
_.extend({name: measurementName, type: 'file'}, component.measurements[measurementName].file)
);
}
if (!_.isEmpty(component.measurements[measurementName].value)) {
measurements.push(
_.extend({name: measurementName, type: 'value'}, component.measurements[measurementName].value)
);
}
});
return {
componentName: component.componentName,
measurements: measurements
};
}
module.exports.build = function build(cloudModel) {
return {
serialNumber: cloudModel.serialNumber,
components: _.map(cloudModel.components, invertMeasurements),
lastUpdate: cloudModel.lastUpdate
};
};