@sis-cc/dotstatsuite-components 15.0.10 → 15.0.11
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/table/factories/getSortedLayoutIndexes.js +2 -2
- package/lib/rules2/src/duplicateObservations.js +1 -1
- package/package.json +1 -1
- package/src/rules/src/table/factories/getSortedLayoutIndexes.js +2 -2
- package/src/rules2/src/duplicateObservations.js +1 -1
- package/test/duplicateObs.test.js +35 -0
|
@@ -56,7 +56,7 @@ var comparator = function comparator(size) {
|
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
// simple call to ramda uniq method is very slow regarding performance
|
|
59
|
+
// simple call to ramda uniq method is very slow regarding performance
|
|
60
60
|
var uniqIndexes = function uniqIndexes(indexes) {
|
|
61
61
|
return R.pipe(R.reduce(function (acc, i) {
|
|
62
62
|
var key = R.join(':', i);
|
|
@@ -71,7 +71,7 @@ var uniqIndexes = function uniqIndexes(indexes) {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
var getSortedLayoutIndexes = exports.getSortedLayoutIndexes = function getSortedLayoutIndexes(layout, observations) {
|
|
74
|
-
var dimIndexes = R.pipe(R.values, R.
|
|
74
|
+
var dimIndexes = R.pipe(R.values, R.map(R.propOr([], 'orderedDimIndexes')))(observations);
|
|
75
75
|
|
|
76
76
|
var headerLength = R.length(layout.header);
|
|
77
77
|
|
|
@@ -13,7 +13,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
13
13
|
|
|
14
14
|
var duplicateObs = exports.duplicateObs = function duplicateObs(dims, observations) {
|
|
15
15
|
var obsValues = R.values(observations);
|
|
16
|
-
if (R.length(
|
|
16
|
+
if (R.length(dims) === 0) {
|
|
17
17
|
return observations;
|
|
18
18
|
}
|
|
19
19
|
var duplicated = R.reduce(function (obs, dim) {
|
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@ const comparator = size => (a, b) => {
|
|
|
33
33
|
return a[i] - b[i];
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
// simple call to ramda uniq method is very slow regarding performance
|
|
36
|
+
// simple call to ramda uniq method is very slow regarding performance
|
|
37
37
|
const uniqIndexes = (indexes) => R.pipe(
|
|
38
38
|
R.reduce(
|
|
39
39
|
(acc, i) => {
|
|
@@ -52,7 +52,7 @@ const uniqIndexes = (indexes) => R.pipe(
|
|
|
52
52
|
)(indexes);
|
|
53
53
|
|
|
54
54
|
export const getSortedLayoutIndexes = (layout, observations) => {
|
|
55
|
-
const dimIndexes = R.pipe(R.values, R.
|
|
55
|
+
const dimIndexes = R.pipe(R.values, R.map(R.propOr([], 'orderedDimIndexes')))(observations);
|
|
56
56
|
|
|
57
57
|
const headerLength = R.length(layout.header);
|
|
58
58
|
|
|
@@ -2,7 +2,7 @@ import * as R from 'ramda';
|
|
|
2
2
|
|
|
3
3
|
export const duplicateObs = (dims, observations) => {
|
|
4
4
|
const obsValues = R.values(observations);
|
|
5
|
-
if (
|
|
5
|
+
if (R.length(dims) === 0) {
|
|
6
6
|
return observations;
|
|
7
7
|
}
|
|
8
8
|
const duplicated = R.reduce(
|
|
@@ -78,6 +78,41 @@ describe('duplicate obs tests', () => {
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
+
expect(duplicateObs(dims, obs)).to.deep.equal(expected);
|
|
82
|
+
});
|
|
83
|
+
it('handle uniq observation case', () => {
|
|
84
|
+
const dims = [{
|
|
85
|
+
id: 'REF_AREA',
|
|
86
|
+
__index: 2,
|
|
87
|
+
values: [
|
|
88
|
+
{ id: 'W' },
|
|
89
|
+
{ id: 'OECD' },
|
|
90
|
+
{ id: 'FRA' },
|
|
91
|
+
{ id: 'GER' },
|
|
92
|
+
{ id: 'EA' },
|
|
93
|
+
{ id: 'GER' },
|
|
94
|
+
{ id: 'FRA' },
|
|
95
|
+
]
|
|
96
|
+
}];
|
|
97
|
+
const obs = {
|
|
98
|
+
'0:0:0': {
|
|
99
|
+
indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'FRA' },
|
|
100
|
+
dimValuesIndexes: [0, 0, 0],
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const expected = {
|
|
104
|
+
'0:0:2': {
|
|
105
|
+
indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'FRA' },
|
|
106
|
+
orderedDimIndexes: [0, 0, 2],
|
|
107
|
+
dimValuesIndexes: [0, 0, 0],
|
|
108
|
+
},
|
|
109
|
+
'0:0:6': {
|
|
110
|
+
indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'FRA' },
|
|
111
|
+
orderedDimIndexes: [0, 0, 6],
|
|
112
|
+
dimValuesIndexes: [0, 0, 0],
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
81
116
|
expect(duplicateObs(dims, obs)).to.deep.equal(expected);
|
|
82
117
|
});
|
|
83
118
|
});
|