@sis-cc/dotstatsuite-components 15.0.15 → 15.0.16
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/preparators/enhanceObservations.js +1 -1
- package/lib/rules/src/table/preparators/parseAttributes.js +7 -2
- package/lib/rules/src/table/preparators/prepareData.js +2 -1
- package/package.json +1 -1
- package/src/rules/src/preparators/enhanceObservations.js +1 -1
- package/src/rules/src/table/preparators/parseAttributes.js +3 -2
- package/src/rules/src/table/preparators/prepareData.js +2 -1
- package/test/enhanceObservations.test.js +81 -0
- package/test/parseAttributes.test.js +6 -3
|
@@ -92,7 +92,7 @@ var getAttributeValue = function getAttributeValue(attribute, valueIndex, option
|
|
|
92
92
|
}
|
|
93
93
|
var value = R.pipe(R.propOr([], 'values'), R.nth(valueIndex))(attribute);
|
|
94
94
|
|
|
95
|
-
if (R.isNil(value) || !R.propOr(true, 'display', value)) {
|
|
95
|
+
if (R.isNil(value) || !R.propOr(true, 'display', value) || R.includes(value.id, R.propOr([], 'rejectedValueIds')(options))) {
|
|
96
96
|
return null;
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -17,11 +17,16 @@ var registerAttrId = function registerAttrId(path, id) {
|
|
|
17
17
|
return R.over(R.lensPath(R.prepend('attributesIdsIndexedByTargets', path)), R.ifElse(R.isNil, R.always([id]), R.append(id)));
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
var
|
|
21
|
-
return
|
|
20
|
+
var _registerAttr = function _registerAttr(rejected) {
|
|
21
|
+
return function (attr) {
|
|
22
|
+
return R.set(R.lensPath(['attributesIndexedByIds', attr.id]), R.over(R.lensProp('values'), R.map(function (v) {
|
|
23
|
+
return R.includes(R.prop('id')(v), rejected) ? null : v;
|
|
24
|
+
}))(attr));
|
|
25
|
+
};
|
|
22
26
|
};
|
|
23
27
|
|
|
24
28
|
var getAttributeRegisters = function getAttributeRegisters(attribute, parsedDimensionsIds, customAttributes) {
|
|
29
|
+
var registerAttr = _registerAttr(R.propOr([], 'rejectedValueIds')(customAttributes));
|
|
25
30
|
if (R.propEq('id', customAttributes.prefscale, attribute)) {
|
|
26
31
|
return [registerAttrId(['prefscale'], attribute.id), registerAttr(attribute)];
|
|
27
32
|
}
|
|
@@ -111,7 +111,8 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
|
|
|
111
111
|
attachmentSeriesIndexes: attachmentSeriesIndexes,
|
|
112
112
|
customAttributes: customAttributes,
|
|
113
113
|
attributesIds: R.concat(seriesAttributesIds, observationsAttributesIds),
|
|
114
|
-
unitsIds: obsUnitsIds
|
|
114
|
+
unitsIds: obsUnitsIds,
|
|
115
|
+
rejectedValueIds: rejectedValueIds
|
|
115
116
|
};
|
|
116
117
|
|
|
117
118
|
var _observations = (0, _getObservations.getObservations)(sdmxJson);
|
package/package.json
CHANGED
|
@@ -94,7 +94,7 @@ const getAttributeValue = (attribute, valueIndex, options) => {
|
|
|
94
94
|
R.nth(valueIndex)
|
|
95
95
|
)(attribute);
|
|
96
96
|
|
|
97
|
-
if (R.isNil(value) || !R.propOr(true, 'display', value)) {
|
|
97
|
+
if (R.isNil(value) || !R.propOr(true, 'display', value) || R.includes(value.id,R.propOr([],'rejectedValueIds')(options))) {
|
|
98
98
|
return null;
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -6,12 +6,13 @@ const registerAttrId = (path, id) => R.over(
|
|
|
6
6
|
R.ifElse(R.isNil, R.always([id]), R.append(id))
|
|
7
7
|
);
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const _registerAttr = rejected=>(attr) => R.set(
|
|
10
10
|
R.lensPath(['attributesIndexedByIds', attr.id]),
|
|
11
|
-
attr
|
|
11
|
+
R.over(R.lensProp('values'),R.map(v=> R.includes(R.prop('id')(v),rejected)? null : v))(attr)
|
|
12
12
|
);
|
|
13
13
|
|
|
14
14
|
const getAttributeRegisters = (attribute, parsedDimensionsIds, customAttributes) => {
|
|
15
|
+
const registerAttr = _registerAttr(R.propOr([],'rejectedValueIds')(customAttributes))
|
|
15
16
|
if (R.propEq('id', customAttributes.prefscale, attribute)) {
|
|
16
17
|
return [registerAttrId(['prefscale'], attribute.id), registerAttr(attribute)];
|
|
17
18
|
}
|
|
@@ -76,7 +76,8 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}, _options=
|
|
|
76
76
|
attachmentSeriesIndexes,
|
|
77
77
|
customAttributes,
|
|
78
78
|
attributesIds: R.concat(seriesAttributesIds, observationsAttributesIds),
|
|
79
|
-
unitsIds: obsUnitsIds
|
|
79
|
+
unitsIds: obsUnitsIds,
|
|
80
|
+
rejectedValueIds
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
const _observations = getObservations(sdmxJson);
|
|
@@ -232,4 +232,85 @@ describe('enhanceObservations tests', () => {
|
|
|
232
232
|
}
|
|
233
233
|
});
|
|
234
234
|
});
|
|
235
|
+
it('should not return attributes with rejectedValueIds [v0,v1]',()=> {
|
|
236
|
+
const attributes = [
|
|
237
|
+
{
|
|
238
|
+
id: 'a0',
|
|
239
|
+
values: [{ id: 'v0' }, { id: 'v1' }, { id: 'v2' }],
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
id: 'a1',
|
|
243
|
+
values: [{ id: 'v0' }],
|
|
244
|
+
},
|
|
245
|
+
];
|
|
246
|
+
|
|
247
|
+
const dimensions = [
|
|
248
|
+
{
|
|
249
|
+
id: 'd0',
|
|
250
|
+
__index: 0,
|
|
251
|
+
values: [
|
|
252
|
+
{ id: 'v0', __index: 0, __indexPosition: 0 },
|
|
253
|
+
{ id: 'v1', __index: 1, __indexPosition: 1 },
|
|
254
|
+
{ id: 'v2', __index: 2, __indexPosition: 2 },
|
|
255
|
+
{ id: 'v3', __index: 3, __indexPosition: 3, display: false }
|
|
256
|
+
]
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
id: 'd1',
|
|
260
|
+
__index: 1,
|
|
261
|
+
values: [
|
|
262
|
+
{ id: 'v0', __index: 0, __indexPosition: 0 }
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
const observations = {
|
|
269
|
+
a: {
|
|
270
|
+
attrValuesIndexes: [0, 0, 0, 0, 0],
|
|
271
|
+
dimValuesIndexes: [0, 0, 0, 0, 0],
|
|
272
|
+
value: 22,
|
|
273
|
+
},
|
|
274
|
+
b: {
|
|
275
|
+
attrValuesIndexes: [1, 0, 1, 1, 0],
|
|
276
|
+
dimValuesIndexes: [0, 0, 0, 1, 0],
|
|
277
|
+
value: 17,
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const options = {
|
|
282
|
+
noDisplayIndexes: [],
|
|
283
|
+
notDisplayedCodes: {
|
|
284
|
+
d0: { values: { v3: 'v3' } },
|
|
285
|
+
},
|
|
286
|
+
attributesIds: ['a0', 'a1'],
|
|
287
|
+
unitsIds: ['d0'],
|
|
288
|
+
rejectedValueIds: ['v0','v1']
|
|
289
|
+
};
|
|
290
|
+
expect(enhanceObservations(dimensions, observations, attributes, options)).to.deep.equal({
|
|
291
|
+
a: {
|
|
292
|
+
attrValuesIndexes: [0, 0, 0, 0, 0],
|
|
293
|
+
dimValuesIndexes: [0, 0, 0, 0, 0],
|
|
294
|
+
value: 22,
|
|
295
|
+
formattedValue: '22',
|
|
296
|
+
units: {
|
|
297
|
+
serieKey: 'x:x:x:x:x'
|
|
298
|
+
},
|
|
299
|
+
attributes: {},
|
|
300
|
+
indexedDimValIds: { d0: 'v0', d1: 'v0'}
|
|
301
|
+
},
|
|
302
|
+
b: {
|
|
303
|
+
attrValuesIndexes: [1, 0, 1, 1, 0],
|
|
304
|
+
dimValuesIndexes: [0, 0, 0, 1, 0],
|
|
305
|
+
value: 17,
|
|
306
|
+
formattedValue: '17',
|
|
307
|
+
units: {
|
|
308
|
+
serieKey: 'x:x:x:x:x'
|
|
309
|
+
},
|
|
310
|
+
attributes: {},
|
|
311
|
+
indexedDimValIds: { d0: 'v0', d1: 'v0'}
|
|
312
|
+
},
|
|
313
|
+
})
|
|
314
|
+
})
|
|
235
315
|
});
|
|
316
|
+
|
|
@@ -27,12 +27,14 @@ const attributes = [
|
|
|
27
27
|
{ id: 'a22', relationship: { observation: {} }, values: [{ id: 'a22v0' }] }, // alternative observation relationship
|
|
28
28
|
{ id: 'REPORTING_YEAR_START_DAY', relationship: { observation: {} }, values: [{ id: 'a22v0' }]},
|
|
29
29
|
{ id: 'REPYEARSTART', relationship: { observation: {} }, values: [{ id: 'a22v0' }]},
|
|
30
|
+
{ id: 'a23', relationship: { observation: {} }, values: [{ id: 'a23v0' },{id : 'a23v1'}]},
|
|
30
31
|
];
|
|
31
32
|
|
|
32
33
|
const customAttributes = {
|
|
33
34
|
prefscale: 'a15',
|
|
34
35
|
decimals: 'a16',
|
|
35
|
-
units: ['d7', 'a20']
|
|
36
|
+
units: ['d7', 'a20'],
|
|
37
|
+
rejectedValueIds:['a23v0']
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
const parsedDimensionsIds = {
|
|
@@ -59,10 +61,11 @@ describe('parseAttributes test', () => {
|
|
|
59
61
|
a18: { id: 'a18', index: 18, relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a18v1' }, null] },
|
|
60
62
|
a19: { id: 'a19', index: 19, relationship: { none: {} }, values: [{ id: 'a19v1' }] },
|
|
61
63
|
a21: { id: 'a21', index: 21, relationship: { dataflow: {} }, values: [{ id: 'a21v0' }] },
|
|
62
|
-
a22: { id: 'a22', index: 22, relationship: { observation: {} }, values: [{ id: 'a22v0' }] },
|
|
64
|
+
a22: { id: 'a22', index: 22, relationship: { observation: {} }, values: [{ id: 'a22v0' }] },
|
|
65
|
+
a23: { id: 'a23', index: 25, relationship: { observation: {} }, values:[null,{id:'a23v1'}] }
|
|
63
66
|
},
|
|
64
67
|
attributesIdsIndexedByTargets: {
|
|
65
|
-
observations: ['a6', 'a18', 'a22'],
|
|
68
|
+
observations: ['a6', 'a18', 'a22','a23'],
|
|
66
69
|
oneValueDimensions: { d1: ['a8', 'a14'] },
|
|
67
70
|
manyValuesDimensions: ['a9', 'a11'],
|
|
68
71
|
dataflow: ['a10', 'a19', 'a21'],
|