@sis-cc/dotstatsuite-components 13.0.1 → 13.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/rules/src/dimension-utils.js +3 -2
- package/lib/rules/src/preparators/enhanceObservations.js +1 -3
- package/lib/rules/src/table/preparators/parseAttributes.js +1 -1
- package/lib/rules/src/table/preparators/prepareData.js +4 -2
- package/lib/rules2/src/getAdvancedAttributes.js +1 -1
- package/package.json +1 -1
- package/src/rules/src/dimension-utils.js +4 -4
- package/src/rules/src/preparators/enhanceObservations.js +1 -3
- package/src/rules/src/table/preparators/parseAttributes.js +1 -1
- package/src/rules/src/table/preparators/prepareData.js +3 -3
- package/src/rules2/src/getAdvancedAttributes.js +1 -1
- package/test/parseAttributes.test.js +8 -4
- package/test/table-prep-perf.test.js +1 -1
|
@@ -28,9 +28,10 @@ var _isEmpty3 = _interopRequireDefault(_isEmpty2);
|
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
29
|
|
|
30
30
|
var dimensionValueDisplay = exports.dimensionValueDisplay = function dimensionValueDisplay(display) {
|
|
31
|
+
var accessors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
31
32
|
return function (dimensionValue) {
|
|
32
|
-
var id = (0, _get3.default)(dimensionValue, 'id', '');
|
|
33
|
-
var name = (0, _get3.default)(dimensionValue, 'name', '');
|
|
33
|
+
var id = (0, _get3.default)(dimensionValue, accessors.id || 'id', '');
|
|
34
|
+
var name = (0, _get3.default)(dimensionValue, accessors.name || 'name', '');
|
|
34
35
|
switch (display) {
|
|
35
36
|
case 'label':
|
|
36
37
|
return (0, _isEmpty3.default)(name) ? '[' + id + ']' : name;
|
|
@@ -123,8 +123,6 @@ var enhanceObservations = exports.enhanceObservations = function enhanceObservat
|
|
|
123
123
|
}, attributes);
|
|
124
124
|
var _obsAttributes = R.pipe(R.indexBy(R.prop('id')), R.props(options.attributesIds || []))(_attributes);
|
|
125
125
|
|
|
126
|
-
var seriesDimensions = R.filter(R.pipe(R.propOr([], 'values'), R.length, R.lt(1)), dimensions);
|
|
127
|
-
|
|
128
126
|
return R.mapObjIndexed(function (observation) {
|
|
129
127
|
var attrValuesIndexes = observation.attrValuesIndexes,
|
|
130
128
|
dimValuesIndexes = observation.dimValuesIndexes;
|
|
@@ -148,7 +146,7 @@ var enhanceObservations = exports.enhanceObservations = function enhanceObservat
|
|
|
148
146
|
attributes: obsAttributes,
|
|
149
147
|
formattedValue: (0, _formatValue.formatValue)(observation, formatAttributesIndexes, attributes),
|
|
150
148
|
orderedDimIndexes: getOrderedDimensionsIndexes(dimensions, dimValuesIndexes),
|
|
151
|
-
units: getObservationUnits(observation,
|
|
149
|
+
units: getObservationUnits(observation, dimensions, _attributes, options),
|
|
152
150
|
indexedDimValIds: indexedDimValIds
|
|
153
151
|
});
|
|
154
152
|
}, observations);
|
|
@@ -32,7 +32,7 @@ var getAttributeRegisters = function getAttributeRegisters(attribute, parsedDime
|
|
|
32
32
|
if (R.propEq('id', customAttributes.decimals, attribute)) {
|
|
33
33
|
return [registerAttrId(['decimals'], attribute.id), registerAttr(attribute)];
|
|
34
34
|
}
|
|
35
|
-
if (R.hasPath(['relationship', 'none'], attribute)) {
|
|
35
|
+
if (R.hasPath(['relationship', 'none'], attribute) || R.hasPath(['relationship', 'dataflow'], attribute)) {
|
|
36
36
|
return [registerAttrId(['dataflow'], attribute.id), registerAttr(attribute)];
|
|
37
37
|
}
|
|
38
38
|
if (R.pathEq(['relationship', 'primaryMeasure'], 'OBS_VALUE', attribute) || R.hasPath(['relationship', 'observation'], attribute)) {
|
|
@@ -116,7 +116,7 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
|
|
|
116
116
|
var attributes = _ref.attributes,
|
|
117
117
|
dimensions = _ref.dimensions;
|
|
118
118
|
return R.merge(attributes.series || {}, dimensions.series || {});
|
|
119
|
-
}, R.
|
|
119
|
+
}, R.keys)(unitsArtefacts);
|
|
120
120
|
var options = {
|
|
121
121
|
attachmentSeriesIndexes: attachmentSeriesIndexes,
|
|
122
122
|
customAttributes: customAttributes,
|
|
@@ -156,7 +156,9 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
|
|
|
156
156
|
return !R.includes(id, customAttributes.flags || []) && !R.includes(id, customAttributes.notes || []);
|
|
157
157
|
}))(headerAttributesIds);
|
|
158
158
|
|
|
159
|
-
var dataflowAdvancedAttributes = (0, _getAdvancedAttributes.getDataflowAdvancedAttributes)(headerAttributes,
|
|
159
|
+
var dataflowAdvancedAttributes = (0, _getAdvancedAttributes.getDataflowAdvancedAttributes)(headerAttributes,
|
|
160
|
+
//oneValueDimensions,
|
|
161
|
+
R.pick(R.keys(parsedDimensionsIds.oneValue), dimensionsIndexedByIds), headerAdvancedAttrIds, R.length(dimensions));
|
|
160
162
|
|
|
161
163
|
var observationsAdvancedAttributesIds = R.filter(function (id) {
|
|
162
164
|
return !R.includes(id, customAttributes.flags || []) && !R.includes(id, customAttributes.notes || []);
|
|
@@ -51,7 +51,7 @@ var getDataflowAdvancedAttributes = exports.getDataflowAdvancedAttributes = func
|
|
|
51
51
|
var vId = R.path(['values', 0, 'id'], dim);
|
|
52
52
|
coordinates = (0, _extends4.default)({}, coordinates, (0, _defineProperty3.default)({}, dId, vId));
|
|
53
53
|
key = R.set(R.lensIndex(dIndex), 0)(key);
|
|
54
|
-
}, attrDimensions);
|
|
54
|
+
}, R.reject(R.isNil, attrDimensions));
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
key = R.join(':', key);
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isEmpty, isNil, get, has, reduce } from 'lodash';
|
|
2
2
|
|
|
3
|
-
export const dimensionValueDisplay = (display) => (dimensionValue) => {
|
|
4
|
-
const id = get(dimensionValue, 'id', '');
|
|
5
|
-
const name = get(dimensionValue, 'name', '');
|
|
3
|
+
export const dimensionValueDisplay = (display, accessors = {}) => (dimensionValue) => {
|
|
4
|
+
const id = get(dimensionValue, accessors.id || 'id', '');
|
|
5
|
+
const name = get(dimensionValue, accessors.name || 'name', '');
|
|
6
6
|
switch(display) {
|
|
7
7
|
case 'label':
|
|
8
8
|
return isEmpty(name) ? `[${id}]` : name;
|
|
@@ -121,8 +121,6 @@ export const enhanceObservations = (dimensions = [], observations = {}, attribut
|
|
|
121
121
|
R.props(options.attributesIds || [])
|
|
122
122
|
)(_attributes);
|
|
123
123
|
|
|
124
|
-
const seriesDimensions = R.filter(R.pipe(R.propOr([], 'values'), R.length, R.lt(1)), dimensions);
|
|
125
|
-
|
|
126
124
|
return R.mapObjIndexed(
|
|
127
125
|
(observation) => {
|
|
128
126
|
const { attrValuesIndexes, dimValuesIndexes } = observation;
|
|
@@ -154,7 +152,7 @@ export const enhanceObservations = (dimensions = [], observations = {}, attribut
|
|
|
154
152
|
attributes: obsAttributes,
|
|
155
153
|
formattedValue: formatValue(observation, formatAttributesIndexes, attributes),
|
|
156
154
|
orderedDimIndexes: getOrderedDimensionsIndexes(dimensions, dimValuesIndexes),
|
|
157
|
-
units: getObservationUnits(observation,
|
|
155
|
+
units: getObservationUnits(observation, dimensions, _attributes, options),
|
|
158
156
|
indexedDimValIds,
|
|
159
157
|
});
|
|
160
158
|
},
|
|
@@ -17,7 +17,7 @@ const getAttributeRegisters = (attribute, parsedDimensionsIds, customAttributes)
|
|
|
17
17
|
if (R.propEq('id', customAttributes.decimals, attribute)) {
|
|
18
18
|
return [registerAttrId(['decimals'], attribute.id), registerAttr(attribute)];
|
|
19
19
|
}
|
|
20
|
-
if (R.hasPath(['relationship', 'none'], attribute)) {
|
|
20
|
+
if (R.hasPath(['relationship', 'none'], attribute) || R.hasPath(['relationship', 'dataflow'], attribute)) {
|
|
21
21
|
return [registerAttrId(['dataflow'], attribute.id), registerAttr(attribute)];
|
|
22
22
|
}
|
|
23
23
|
if (R.pathEq(['relationship', 'primaryMeasure'], 'OBS_VALUE', attribute) || R.hasPath(['relationship', 'observation'], attribute)) {
|
|
@@ -81,8 +81,7 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
|
|
|
81
81
|
const observationsAttributesIds = R.propOr([], 'observations', attributesIdsIndexedByTargets);
|
|
82
82
|
const obsUnitsIds = R.pipe(
|
|
83
83
|
({ attributes, dimensions }) => R.merge(attributes.series || {}, dimensions.series || {}),
|
|
84
|
-
R.
|
|
85
|
-
R.pluck('id')
|
|
84
|
+
R.keys
|
|
86
85
|
)(unitsArtefacts);
|
|
87
86
|
const options = {
|
|
88
87
|
attachmentSeriesIndexes,
|
|
@@ -156,7 +155,8 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
|
|
|
156
155
|
|
|
157
156
|
const dataflowAdvancedAttributes = getDataflowAdvancedAttributes(
|
|
158
157
|
headerAttributes,
|
|
159
|
-
oneValueDimensions,
|
|
158
|
+
//oneValueDimensions,
|
|
159
|
+
R.pick(R.keys(parsedDimensionsIds.oneValue), dimensionsIndexedByIds),
|
|
160
160
|
headerAdvancedAttrIds,
|
|
161
161
|
R.length(dimensions)
|
|
162
162
|
);
|
|
@@ -27,7 +27,9 @@ const attributes = [
|
|
|
27
27
|
{ id: 'a17', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a17v1' }] }, // blacklisted
|
|
28
28
|
{ id: 'a18', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a18v1' }, { id: 'a18v2' }] }, // blacklisted value
|
|
29
29
|
{ id: 'a19', relationship: { none: {} }, values: [{ id: 'a19v1' }] }, // dataset relationship
|
|
30
|
-
{ id: 'a20', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a20v1' }] } // units attribute
|
|
30
|
+
{ id: 'a20', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a20v1' }] }, // units attribute
|
|
31
|
+
{ id: 'a21', relationship: { dataflow: {} }, values: [{ id: 'a21v0' }] }, // alternative dataflow relationship
|
|
32
|
+
{ id: 'a22', relationship: { observation: {} }, values: [{ id: 'a22v0' }] }, // alternative observation relationship
|
|
31
33
|
];
|
|
32
34
|
|
|
33
35
|
const customAttributes = {
|
|
@@ -58,13 +60,15 @@ describe('parseAttributes test', () => {
|
|
|
58
60
|
a15: { id: 'a15', index: 15, relationship: { dimensions: ['d3'] }, values: [{ id: 'a15v1' }] },
|
|
59
61
|
a16: { id: 'a16', index: 16, relationship: { dimensions: ['d6'] }, values: [{ id: 'a16v1' }] },
|
|
60
62
|
a18: { id: 'a18', index: 18, relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a18v1' }, null] },
|
|
61
|
-
a19: { id: 'a19', index: 19, relationship: { none: {} }, values: [{ id: 'a19v1' }] }
|
|
63
|
+
a19: { id: 'a19', index: 19, relationship: { none: {} }, values: [{ id: 'a19v1' }] },
|
|
64
|
+
a21: { id: 'a21', index: 21, relationship: { dataflow: {} }, values: [{ id: 'a21v0' }] },
|
|
65
|
+
a22: { id: 'a22', index: 22, relationship: { observation: {} }, values: [{ id: 'a22v0' }] },
|
|
62
66
|
},
|
|
63
67
|
attributesIdsIndexedByTargets: {
|
|
64
|
-
observations: ['a6', 'a18'],
|
|
68
|
+
observations: ['a6', 'a18', 'a22'],
|
|
65
69
|
oneValueDimensions: { d1: ['a8', 'a14'] },
|
|
66
70
|
manyValuesDimensions: ['a9', 'a11'],
|
|
67
|
-
dataflow: ['a10', 'a19'],
|
|
71
|
+
dataflow: ['a10', 'a19', 'a21'],
|
|
68
72
|
series: ['a12', 'a13'],
|
|
69
73
|
prefscale: ['a15'],
|
|
70
74
|
decimals: ['a16'],
|
|
@@ -33,7 +33,7 @@ describe('table preparators performance tests', () => {
|
|
|
33
33
|
OBS_STATUS: { id: 'OBS_STATUS', values: { A: 'A' } },
|
|
34
34
|
UNIT_MULT: { id: 'UNIT_MULT', values: { '0': '0' } }
|
|
35
35
|
},
|
|
36
|
-
unitsIds: ['
|
|
36
|
+
unitsIds: ['UNIT_MULT', 'BASE_PER']
|
|
37
37
|
};
|
|
38
38
|
expect(
|
|
39
39
|
enhanceObservations(multiHierRowsDim, multiHierRowsObs, multiHierRowsAttr, options)
|