@sis-cc/dotstatsuite-components 9.1.0 → 9.2.0

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.
Files changed (80) hide show
  1. package/lib/rules/src/preparators/enhanceObservations.js +155 -0
  2. package/lib/rules/src/preparators/formatValue.js +77 -0
  3. package/lib/rules/src/preparators/getDimensions.js +55 -0
  4. package/lib/rules/src/preparators/getDisplay.js +32 -0
  5. package/lib/rules/src/preparators/getObservations.js +27 -0
  6. package/lib/rules/src/table/factories/getCells.js +1 -3
  7. package/lib/rules/src/table/factories/getLayoutData.js +102 -161
  8. package/lib/rules/src/table/factories/getSortedLayoutIndexes.js +118 -0
  9. package/lib/rules/src/table/factories/getTableData.js +12 -10
  10. package/lib/rules/src/table/factories/refineLayoutSize.js +210 -0
  11. package/lib/rules/src/table/preparators/prepareData.js +23 -23
  12. package/lib/rules/src/table/units/appendUnitsInLayoutDataEntry.js +10 -10
  13. package/lib/rules/src/table/units/getAttachmentSeriesIndexes.js +1 -1
  14. package/lib/rules/src/table/units/getUnitsSeries.js +31 -0
  15. package/lib/rules/src/v8-transformer.js +3 -2
  16. package/package.json +2 -2
  17. package/src/rules/src/preparators/enhanceObservations.js +163 -0
  18. package/src/rules/src/preparators/formatValue.js +73 -0
  19. package/src/rules/src/preparators/getDimensions.js +49 -0
  20. package/src/rules/src/preparators/getDisplay.js +20 -0
  21. package/src/rules/src/preparators/getObservations.js +19 -0
  22. package/src/rules/src/table/factories/getCells.js +3 -7
  23. package/src/rules/src/table/factories/getLayoutData.js +135 -184
  24. package/src/rules/src/table/factories/getSortedLayoutIndexes.js +108 -0
  25. package/src/rules/src/table/factories/getTableData.js +10 -10
  26. package/src/rules/src/table/factories/refineLayoutSize.js +224 -0
  27. package/src/rules/src/table/preparators/prepareData.js +23 -32
  28. package/src/rules/src/table/units/appendUnitsInLayoutDataEntry.js +15 -18
  29. package/src/rules/src/table/units/getAttachmentSeriesIndexes.js +2 -1
  30. package/src/rules/src/table/units/getUnitsSeries.js +20 -0
  31. package/src/rules/src/v8-transformer.js +4 -2
  32. package/test/appendUnitsInLayoutDataEntry.test.js +3 -3
  33. package/test/enhanceObservations.test.js +270 -0
  34. package/test/getAttachmentSeriesIndexes.test.js +1 -1
  35. package/test/getCells.test.js +4 -39
  36. package/test/getLayoutData2.test.js +194 -0
  37. package/test/getOneValueDimensions.test.js +1 -1
  38. package/test/getSortedLayoutIndexes.test.js +80 -0
  39. package/test/getUnitsArtefacts.test.js +1 -1
  40. package/test/getUnitsSeries.test.js +64 -0
  41. package/test/mocks/table-layout-multi-hierarchies--layout.json +621 -0
  42. package/test/mocks/table-layout-multi-hierarchies--layoutData.json +32410 -0
  43. package/test/mocks/table-layout-multi-hierarchies--layoutIndexes.json +2760 -0
  44. package/test/mocks/table-layout-multi-hierarchies--observations.json +30688 -0
  45. package/test/mocks/table-layout-multi-hierarchies--sizedIndexes.json +2761 -0
  46. package/test/mocks/table-layout-truncation1--layout.json +27469 -0
  47. package/test/mocks/table-layout-truncation1--layoutData.json +19413 -0
  48. package/test/mocks/table-layout-truncation1--layoutIndexes.json +7512 -0
  49. package/test/mocks/table-layout-truncation1--observations.json +70002 -0
  50. package/test/mocks/table-layout-truncation1--sizedIndexes.json +3010 -0
  51. package/test/mocks/table-prep-multi-hierarchies--attributes.json +44 -0
  52. package/test/mocks/table-prep-multi-hierarchies--dimensions.json +688 -0
  53. package/test/mocks/table-prep-multi-hierarchies--enhancedObservations.json +19696 -0
  54. package/test/mocks/table-prep-multi-hierarchies--observations.json +8246 -0
  55. package/test/mocks/table-prep-multi-hierarchies--sdmxJson.json +2985 -0
  56. package/test/mocks/table-prep-truncation1--dimensions.json +35057 -0
  57. package/test/mocks/table-prep-truncation1--enhancedObservations.json +70002 -0
  58. package/test/mocks/table-prep-truncation1--observations.json +27502 -0
  59. package/test/mocks/table-prep-truncation1--sdmxJson.json +55103 -0
  60. package/test/mocks/table-prep-units--observations.json +284286 -0
  61. package/test/mocks/table-prep-units--unitsSeries.json +41042 -0
  62. package/test/parseAttributes.test.js +1 -1
  63. package/test/refineLayoutSize.test.js +415 -0
  64. package/test/table-layout-perf.test.js +74 -0
  65. package/test/table-prep-perf.test.js +65 -0
  66. package/lib/rules/src/table/factories/getSortedLayoutData.js +0 -145
  67. package/lib/rules/src/table/factories/refineLayoutHierarchy.js +0 -61
  68. package/lib/rules/src/table/preparators/parseObservations.js +0 -76
  69. package/lib/rules/src/table/units/getUnitsSeriesOccurences.js +0 -39
  70. package/src/rules/src/table/factories/getSortedLayoutData.js +0 -133
  71. package/src/rules/src/table/factories/refineLayoutHierarchy.js +0 -64
  72. package/src/rules/src/table/preparators/parseObservations.js +0 -81
  73. package/src/rules/src/table/units/getUnitsSeriesOccurences.js +0 -51
  74. package/test/appendUnitsInLayoutData.test.js +0 -248
  75. package/test/getLayoutData.test.js +0 -311
  76. package/test/getSortedLayoutData.test.js +0 -382
  77. package/test/getUnitsSeriesOccurences.test.js +0 -133
  78. package/test/parseObservations.test.js +0 -116
  79. package/test/refineDimSeriesUnits.test.js +0 -24
  80. package/test/refineLayoutHierarchy.test.js +0 -79
@@ -1,6 +1,6 @@
1
1
  import { expect } from 'chai';
2
2
  import { parseAttributes } from '../src/rules/src/table/preparators/parseAttributes';
3
- import { getDisplay } from '../src/rules/src/table/preparators/getDisplay';
3
+ import { getDisplay } from '../src/rules/src/preparators/getDisplay';
4
4
 
5
5
  const noDisplayIndexes = [0, 5, 10];
6
6
  const notDisplayedCodes = { a17: { id: 'a17' }, a18: { values: { a18v2: 'a18v2' } } };
@@ -0,0 +1,415 @@
1
+ import { expect } from 'chai';
2
+ import { refineLayoutSize } from '../src/rules/src/table/factories/refineLayoutSize';
3
+
4
+ const observations1 = {
5
+ '0:0:0': { orderedDimIndexes: [0, 0, 0] },
6
+ '0:0:1': { orderedDimIndexes: [0, 0, 1] },
7
+ '0:0:2': { orderedDimIndexes: [0, 0, 2] },
8
+ '0:1:0': { orderedDimIndexes: [0, 1, 0] },
9
+ '0:1:1': { orderedDimIndexes: [0, 1, 1] },
10
+ '0:1:2': { orderedDimIndexes: [0, 1, 2] },
11
+ '0:2:0': { orderedDimIndexes: [0, 2, 0] },
12
+ '0:2:1': { orderedDimIndexes: [0, 2, 1] },
13
+ '0:2:2': { orderedDimIndexes: [0, 2, 2] },
14
+ '1:0:0': { orderedDimIndexes: [1, 0, 0] },
15
+ '1:0:1': { orderedDimIndexes: [1, 0, 1] },
16
+ '1:0:2': { orderedDimIndexes: [1, 0, 2] },
17
+ '1:1:0': { orderedDimIndexes: [1, 1, 0] },
18
+ '1:1:1': { orderedDimIndexes: [1, 1, 1] },
19
+ '1:1:2': { orderedDimIndexes: [1, 1, 2] },
20
+ '1:2:0': { orderedDimIndexes: [1, 2, 0] },
21
+ '1:2:1': { orderedDimIndexes: [1, 2, 1] },
22
+ '1:2:2': { orderedDimIndexes: [1, 2, 2] },
23
+ '2:0:0': { orderedDimIndexes: [2, 0, 0] },
24
+ '2:0:1': { orderedDimIndexes: [2, 0, 1] },
25
+ '2:0:2': { orderedDimIndexes: [2, 0, 2] },
26
+ '2:1:0': { orderedDimIndexes: [2, 1, 0] },
27
+ '2:1:1': { orderedDimIndexes: [2, 1, 1] },
28
+ '2:1:2': { orderedDimIndexes: [2, 1, 2] },
29
+ '2:2:0': { orderedDimIndexes: [2, 2, 0] },
30
+ '2:2:1': { orderedDimIndexes: [2, 2, 1] },
31
+ '2:2:2': { orderedDimIndexes: [2, 2, 2] },
32
+ };
33
+
34
+ const partialObservations1 = {
35
+ '0:0:0': { orderedDimIndexes: [0, 0, 0] },
36
+ '0:0:1': { orderedDimIndexes: [0, 0, 1] },
37
+ '0:0:2': { orderedDimIndexes: [0, 0, 2] },
38
+ '0:1:0': { orderedDimIndexes: [0, 1, 0] },
39
+ '0:1:1': { orderedDimIndexes: [0, 1, 1] },
40
+ '0:1:2': { orderedDimIndexes: [0, 1, 2] },
41
+ '0:2:0': { orderedDimIndexes: [0, 2, 0] },
42
+ '0:2:1': { orderedDimIndexes: [0, 2, 1] },
43
+ '0:2:2': { orderedDimIndexes: [0, 2, 2] },
44
+ '1:2:0': { orderedDimIndexes: [1, 2, 0] },
45
+ '1:2:1': { orderedDimIndexes: [1, 2, 1] },
46
+ '1:2:2': { orderedDimIndexes: [1, 2, 2] },
47
+ '2:0:0': { orderedDimIndexes: [2, 0, 0] },
48
+ '2:0:1': { orderedDimIndexes: [2, 0, 1] },
49
+ '2:0:2': { orderedDimIndexes: [2, 0, 2] },
50
+ '2:1:0': { orderedDimIndexes: [2, 1, 0] },
51
+ '2:1:1': { orderedDimIndexes: [2, 1, 1] },
52
+ '2:1:2': { orderedDimIndexes: [2, 1, 2] },
53
+ '2:2:0': { orderedDimIndexes: [2, 2, 0] },
54
+ '2:2:1': { orderedDimIndexes: [2, 2, 1] },
55
+ '2:2:2': { orderedDimIndexes: [2, 2, 2] },
56
+ };
57
+
58
+ const partialObservations2 = {
59
+ '0:0:0': { orderedDimIndexes: [0, 0, 0] },
60
+ '0:1:0': { orderedDimIndexes: [0, 1, 0] },
61
+ '0:2:0': { orderedDimIndexes: [0, 2, 0] },
62
+ '1:0:0': { orderedDimIndexes: [1, 0, 0] },
63
+ '1:1:0': { orderedDimIndexes: [1, 1, 0] },
64
+ '1:2:0': { orderedDimIndexes: [1, 2, 0] },
65
+ '2:0:0': { orderedDimIndexes: [2, 0, 0] },
66
+ '2:0:1': { orderedDimIndexes: [2, 0, 1] },
67
+ '2:0:2': { orderedDimIndexes: [2, 0, 2] },
68
+ '2:1:0': { orderedDimIndexes: [2, 1, 0] },
69
+ '2:1:1': { orderedDimIndexes: [2, 1, 1] },
70
+ '2:1:2': { orderedDimIndexes: [2, 1, 2] },
71
+ '2:2:0': { orderedDimIndexes: [2, 2, 0] },
72
+ '2:2:1': { orderedDimIndexes: [2, 2, 1] },
73
+ '2:2:2': { orderedDimIndexes: [2, 2, 2] },
74
+ };
75
+
76
+ /*
77
+ | 0 | 1 | 2 |
78
+ |0|1|2|0|1|2|0|1|2|
79
+ |0|-|-|-|-|-|-|x|x|x|
80
+ |1|x|x|x|x|x|x|x|x|x|
81
+ |2|-|-|-|-|-|-|x|x|x|
82
+ */
83
+
84
+ const partialObservations3 = {
85
+ '0:0:2': { orderedDimIndexes: [0, 0, 2] },
86
+ '0:1:0': { orderedDimIndexes: [0, 1, 0] },
87
+ '0:1:1': { orderedDimIndexes: [0, 1, 1] },
88
+ '0:1:2': { orderedDimIndexes: [0, 1, 2] },
89
+ '0:2:2': { orderedDimIndexes: [0, 2, 2] },
90
+ '1:0:2': { orderedDimIndexes: [1, 0, 2] },
91
+ '1:1:0': { orderedDimIndexes: [1, 1, 0] },
92
+ '1:1:1': { orderedDimIndexes: [1, 1, 1] },
93
+ '1:1:2': { orderedDimIndexes: [1, 1, 2] },
94
+ '1:2:2': { orderedDimIndexes: [1, 2, 2] },
95
+ '2:0:2': { orderedDimIndexes: [2, 0, 2] },
96
+ '2:1:0': { orderedDimIndexes: [2, 1, 0] },
97
+ '2:1:1': { orderedDimIndexes: [2, 1, 1] },
98
+ '2:1:2': { orderedDimIndexes: [2, 1, 2] },
99
+ '2:2:2': { orderedDimIndexes: [2, 2, 2] },
100
+ };
101
+
102
+ describe('refineLayoutSize tests', () => {
103
+ it('no changes under limit', () => {
104
+ const layout = {
105
+ header: [{ __index: 0 }],
106
+ sections: [{ __index: 1 }],
107
+ rows: [{ __index: 2 }]
108
+ };
109
+
110
+ const layoutIndexes = {
111
+ header: [[0], [1], [2]],
112
+ sections: [
113
+ [[0], [[0], [1], [2]]],
114
+ [[1], [[0], [1], [2]]],
115
+ [[2], [[0], [1], [2]]]
116
+ ]
117
+ };
118
+
119
+ const expected = {
120
+ truncated: false,
121
+ header: [[0], [1], [2]],
122
+ sections: [
123
+ [[0], [[0], [1], [2]]],
124
+ [[1], [[0], [1], [2]]],
125
+ [[2], [[0], [1], [2]]]
126
+ ]
127
+ };
128
+ expect(
129
+ refineLayoutSize({
130
+ layout,
131
+ observations: observations1,
132
+ limit: 60,
133
+ })(layoutIndexes)
134
+ ).to.deep.equal(expected);
135
+ });
136
+ it('no headers', () => {
137
+ const layout = {
138
+ header: [],
139
+ sections: [],
140
+ rows: [{ __index: 0 }, { __index: 1 }, { __index: 2 }]
141
+ };
142
+
143
+ const layoutIndexes = {
144
+ header: [[]],
145
+ sections: [
146
+ [
147
+ [],
148
+ [
149
+ [0, 0, 0],
150
+ [0, 0, 1],
151
+ [0, 0, 2],
152
+ [0, 1, 0],
153
+ [0, 1, 1],
154
+ [0, 1, 2],
155
+ [0, 2, 0],
156
+ [0, 2, 1],
157
+ [0, 2, 2],
158
+ [1, 0, 0],
159
+ [1, 0, 1],
160
+ [1, 0, 2],
161
+ [1, 1, 0],
162
+ [1, 1, 1],
163
+ [1, 1, 2],
164
+ [1, 2, 0],
165
+ [1, 2, 1],
166
+ [1, 2, 2],
167
+ [2, 0, 0],
168
+ [2, 0, 1],
169
+ [2, 0, 2],
170
+ [2, 1, 0],
171
+ [2, 1, 1],
172
+ [2, 1, 2],
173
+ [2, 2, 0],
174
+ [2, 2, 1],
175
+ [2, 2, 2]
176
+ ]
177
+ ]
178
+ ]
179
+ };
180
+
181
+ const expected = {
182
+ truncated: true,
183
+ header: [[]],
184
+ sections: [
185
+ [
186
+ [],
187
+ [
188
+ [0, 0, 0],
189
+ [0, 0, 1],
190
+ [0, 0, 2],
191
+ [0, 1, 0],
192
+ [0, 1, 1],
193
+ [0, 1, 2],
194
+ [0, 2, 0],
195
+ [0, 2, 1],
196
+ [0, 2, 2],
197
+ [1, 0, 0],
198
+ [1, 0, 1],
199
+ [1, 0, 2],
200
+ [1, 1, 0],
201
+ [1, 1, 1],
202
+ [1, 1, 2],
203
+ [1, 2, 0],
204
+ [1, 2, 1],
205
+ [1, 2, 2],
206
+ [2, 0, 0],
207
+ [2, 0, 1]
208
+ ]
209
+ ]
210
+ ]
211
+ };
212
+
213
+ expect(
214
+ refineLayoutSize({
215
+ layout,
216
+ observations: observations1,
217
+ limit: 105
218
+ })(layoutIndexes)
219
+ ).to.deep.equal(expected);
220
+ });
221
+ it('no rows', () => {
222
+
223
+ const layout = {
224
+ header: [{ __index: 0 }, { __index: 1 }, { __index: 2 }],
225
+ sections: [],
226
+ rows: [],
227
+ };
228
+
229
+ const layoutIndexes = {
230
+ header: [
231
+ [0, 0, 0],
232
+ [0, 0, 1],
233
+ [0, 0, 2],
234
+ [0, 1, 0],
235
+ [0, 1, 1],
236
+ [0, 1, 2],
237
+ [0, 2, 0],
238
+ [0, 2, 1],
239
+ [0, 2, 2],
240
+ [1, 0, 0],
241
+ [1, 0, 1],
242
+ [1, 0, 2],
243
+ [1, 1, 0],
244
+ [1, 1, 1],
245
+ [1, 1, 2],
246
+ [1, 2, 0],
247
+ [1, 2, 1],
248
+ [1, 2, 2],
249
+ [2, 0, 0],
250
+ [2, 0, 1],
251
+ [2, 0, 2],
252
+ [2, 1, 0],
253
+ [2, 1, 1],
254
+ [2, 1, 2],
255
+ [2, 2, 0],
256
+ [2, 2, 1],
257
+ [2, 2, 2]
258
+ ],
259
+ sections: [[[], [[]]]],
260
+ };
261
+
262
+ const expected = {
263
+ truncated: true,
264
+ header: [
265
+ [0, 0, 0],
266
+ [0, 0, 1],
267
+ [0, 0, 2],
268
+ [0, 1, 0],
269
+ [0, 1, 1],
270
+ [0, 1, 2],
271
+ [0, 2, 0],
272
+ [0, 2, 1],
273
+ [0, 2, 2],
274
+ [1, 0, 0],
275
+ [1, 0, 1],
276
+ [1, 0, 2],
277
+ [1, 1, 0],
278
+ [1, 1, 1],
279
+ [1, 1, 2],
280
+ [1, 2, 0],
281
+ [1, 2, 1],
282
+ [1, 2, 2],
283
+ [2, 0, 0],
284
+ [2, 0, 1]
285
+ ],
286
+ sections: [[[], [[]]]],
287
+ };
288
+ expect(
289
+ refineLayoutSize({
290
+ layout,
291
+ observations: observations1,
292
+ limit: 105
293
+ })(layoutIndexes)
294
+ ).to.deep.equal(expected);
295
+ });
296
+ it('some empty headers to clean after cut', () => {
297
+ const layout = {
298
+ header: [{ __index: 0 }],
299
+ sections: [{ __index: 1 }],
300
+ rows: [{ __index: 2 }]
301
+ };
302
+
303
+ const layoutIndexes = {
304
+ header: [[0], [1], [2]],
305
+ sections: [
306
+ [[0], [[0], [1], [2]]],
307
+ [[1], [[0], [1], [2]]],
308
+ [[2], [[0], [1], [2]]]
309
+ ]
310
+ };
311
+
312
+ const expected = {
313
+ truncated: true,
314
+ header: [[0],[2]],
315
+ sections: [
316
+ [[0], [[0], [1], [2]]],
317
+ [[1], [[0], [1], [2]]]
318
+ ]
319
+ };
320
+
321
+ expect(
322
+ refineLayoutSize({
323
+ layout,
324
+ observations: partialObservations1,
325
+ limit: 45,
326
+ })(layoutIndexes)
327
+ ).to.deep.equal(expected);
328
+ });
329
+ it('multiple empty rows to clean after cut', () => {
330
+ const layout = {
331
+ header: [{ __index: 0 }, { __index: 1 }],
332
+ sections: [],
333
+ rows: [{ __index: 2 }],
334
+ };
335
+
336
+ const layoutIndexes = {
337
+ header: [
338
+ [0, 0],
339
+ [0, 1],
340
+ [0, 2],
341
+ [1, 0],
342
+ [1, 1],
343
+ [1, 2],
344
+ [2, 0],
345
+ [2, 1],
346
+ [2, 2]
347
+ ],
348
+ sections: [[[], [[0], [1], [2]]]]
349
+ };
350
+
351
+ const expected = {
352
+ truncated:true,
353
+ header: [
354
+ [0, 0],
355
+ [0, 1],
356
+ [0, 2],
357
+ [1, 0],
358
+ [1, 1],
359
+ [1, 2],
360
+ ],
361
+ sections: [[[], [[0]]]]
362
+ };
363
+
364
+ expect(
365
+ refineLayoutSize({
366
+ layout,
367
+ observations: partialObservations2,
368
+ limit: 50,
369
+ })(layoutIndexes)
370
+ ).to.deep.equal(expected);
371
+ });
372
+ it('multiple empty rows to clean after cut with mixed dimensions order in header', () => {
373
+ const layout = {
374
+ header: [{ __index: 2 }, { __index: 0 }],
375
+ sections: [],
376
+ rows: [{ __index: 1 }],
377
+ };
378
+
379
+ const layoutIndexes = {
380
+ header: [
381
+ [0, 0],
382
+ [0, 1],
383
+ [0, 2],
384
+ [1, 0],
385
+ [1, 1],
386
+ [1, 2],
387
+ [2, 0],
388
+ [2, 1],
389
+ [2, 2]
390
+ ],
391
+ sections: [[[], [[0], [1], [2]]]]
392
+ };
393
+
394
+ const expected = {
395
+ truncated: true,
396
+ header: [
397
+ [0, 0],
398
+ [0, 1],
399
+ [0, 2],
400
+ [1, 0],
401
+ [1, 1],
402
+ [1, 2]
403
+ ],
404
+ sections: [[[], [[1]]]]
405
+ };
406
+
407
+ expect(
408
+ refineLayoutSize({
409
+ layout,
410
+ observations: partialObservations3,
411
+ limit: 50,
412
+ })(layoutIndexes)
413
+ ).to.deep.equal(expected);
414
+ });
415
+ });
@@ -0,0 +1,74 @@
1
+ import { expect } from 'chai';
2
+ import { getSortedLayoutIndexes } from '../src/rules/src/table/factories/getSortedLayoutIndexes';
3
+ import { refineLayoutSize } from '../src/rules/src/table/factories/refineLayoutSize';
4
+ import { getLayoutData } from '../src/rules/src/table/factories/getLayoutData';
5
+ import multiHierRowsLayout from './mocks/table-layout-multi-hierarchies--layout.json'
6
+ import multiHierRowsObs from './mocks/table-layout-multi-hierarchies--observations.json'
7
+ import multiHierRowsLayoutIndexes from './mocks/table-layout-multi-hierarchies--layoutIndexes.json'
8
+ import multiHierRowsSizedIndexes from './mocks/table-layout-multi-hierarchies--sizedIndexes.json'
9
+ import multiHierRowsLayoutData from './mocks/table-layout-multi-hierarchies--layoutData.json'
10
+ import truncation1Layout from './mocks/table-layout-truncation1--layout.json'
11
+ import truncation1Obs from './mocks/table-layout-truncation1--observations.json'
12
+ import truncation1LayoutIndexes from './mocks/table-layout-truncation1--layoutIndexes.json'
13
+ import truncation1SizedIndexes from './mocks/table-layout-truncation1--sizedIndexes.json'
14
+ import truncation1LayoutData from './mocks/table-layout-truncation1--layoutData.json'
15
+ import * as R from 'ramda';
16
+
17
+ describe('table LayoutData performance tests', () => {
18
+ it('multi hierarchical rows getSortedLayoutIndexes test', function() {
19
+ this.timeout(2000);
20
+ expect(
21
+ getSortedLayoutIndexes(multiHierRowsLayout, multiHierRowsObs)
22
+ ).to.deep.equal(multiHierRowsLayoutIndexes);
23
+ });
24
+ it('multi hierarchical rows refineLayoutSize test', function() {
25
+ this.timeout(2000);
26
+ expect(
27
+ refineLayoutSize({ layout: multiHierRowsLayout, observations: multiHierRowsObs, limit: 3000 })(multiHierRowsLayoutIndexes)
28
+ ).to.deep.equal(multiHierRowsSizedIndexes);
29
+ });
30
+ it('multi hierarchical rows getLayoutData test', function() {
31
+ this.timeout(2000);
32
+ expect(
33
+ getLayoutData(multiHierRowsSizedIndexes, multiHierRowsLayout)
34
+ ).to.deep.equal(multiHierRowsLayoutData);
35
+ });
36
+ it('multi hierarchical rows test', function() {
37
+ this.timeout(2000);
38
+ expect(
39
+ R.pipe(
40
+ getSortedLayoutIndexes,
41
+ refineLayoutSize({ layout: multiHierRowsLayout, observations: multiHierRowsObs, limit: 3000 }),
42
+ indexes => getLayoutData(indexes, multiHierRowsLayout)
43
+ )(multiHierRowsLayout, multiHierRowsObs)
44
+ ).to.deep.equal(multiHierRowsLayoutData);
45
+ });
46
+ it('truncation1 getSortedLayoutIndexes test', function() {
47
+ this.timeout(2000);
48
+ expect(
49
+ getSortedLayoutIndexes(truncation1Layout, truncation1Obs)
50
+ ).to.deep.equal(truncation1LayoutIndexes);
51
+ });
52
+ it('truncation1 refineLayoutSize test', function() {
53
+ this.timeout(2000);
54
+ expect(
55
+ refineLayoutSize({ layout: truncation1Layout, observations: truncation1Obs, limit: 3000 })(truncation1LayoutIndexes)
56
+ ).to.deep.equal(truncation1SizedIndexes);
57
+ });
58
+ it('truncation1 getLayoutData test', function() {
59
+ this.timeout(2000);
60
+ expect(
61
+ getLayoutData(truncation1SizedIndexes, truncation1Layout)
62
+ ).to.deep.equal(truncation1LayoutData);
63
+ });
64
+ it('truncation1 test', function() {
65
+ this.timeout(2500);
66
+ expect(
67
+ R.pipe(
68
+ getSortedLayoutIndexes,
69
+ refineLayoutSize({ layout: truncation1Layout, observations: truncation1Obs, limit: 3000 }),
70
+ indexes => getLayoutData(indexes, truncation1Layout)
71
+ )(truncation1Layout, truncation1Obs)
72
+ ).to.deep.equal(truncation1LayoutData);
73
+ });
74
+ });
@@ -0,0 +1,65 @@
1
+ import { expect } from 'chai';
2
+ import { enhanceObservations } from '../src/rules/src/preparators/enhanceObservations';
3
+ import { getUnitsSeries } from '../src/rules/src/table/units/getUnitsSeries';
4
+ import multiHierRowsDim from './mocks/table-prep-multi-hierarchies--dimensions.json';
5
+ import multiHierRowsAttr from './mocks/table-prep-multi-hierarchies--attributes.json';
6
+ import multiHierRowsObs from './mocks/table-prep-multi-hierarchies--observations.json';
7
+ import multiHierEnhancedObs from './mocks/table-prep-multi-hierarchies--enhancedObservations.json';
8
+
9
+ import truncate1Dim from './mocks/table-prep-truncation1--dimensions.json';
10
+ import truncate1Obs from './mocks/table-prep-truncation1--observations.json';
11
+ import truncate1EnhancedObs from './mocks/table-prep-truncation1--enhancedObservations.json';
12
+
13
+ import unitsObs from './mocks/table-prep-units--observations.json';
14
+ import unitsSeries from './mocks/table-prep-units--unitsSeries.json';
15
+
16
+ import numeral from 'numeral';
17
+
18
+ numeral.register('locale', 'test', { delimiters: { thousands: " ", decimal: "." } });
19
+ describe('table preparators performance tests', () => {
20
+ it('multi hierarchical rows enhanceObservations test', function() {
21
+ numeral.locale('test');
22
+ this.timeout(3000);
23
+ const options = {
24
+ attachmentSeriesIndexes: [],
25
+ attributesIds: ['OBS_STATUS'],
26
+ customAttributes: {
27
+ flags: ['OBS_STATUS', 'CONF_STATUS'],
28
+ decimals: 'DECIMALS',
29
+ prefscale: 'PREF_SCALE'
30
+ },
31
+ noDisplayIndexes: [4],
32
+ notDisplayedCodes: {
33
+ OBS_STATUS: { id: 'OBS_STATUS', values: { A: 'A' } },
34
+ UNIT_MULT: { id: 'UNIT_MULT', values: { '0': '0' } }
35
+ },
36
+ unitsIds: ['UNIT_MEASURE', 'UNIT_MULT', 'BASE_PER']
37
+ };
38
+ expect(
39
+ enhanceObservations(multiHierRowsDim, multiHierRowsObs, multiHierRowsAttr, options)
40
+ ).to.deep.equal(multiHierEnhancedObs);
41
+ });
42
+ it('2500 observations enhanceObservations test', function() {
43
+ numeral.locale('test');
44
+ this.timeout(5000);
45
+ const options = {
46
+ attachmentSeriesIndexes: [],
47
+ attributesIds: [],
48
+ customAttributes: {
49
+ flags: ['OBS_STATUS', 'CONF_STATUS'],
50
+ decimals: 'DECIMALS',
51
+ prefscale: 'PREF_SCALE'
52
+ },
53
+ noDisplayIndexes: [],
54
+ notDisplayedCodes: {},
55
+ unitsIds: ['UNIT_MEASURE', 'UNIT_MULT', 'BASE_PER']
56
+ };
57
+ expect(
58
+ enhanceObservations(truncate1Dim, truncate1Obs, [], options)
59
+ ).to.deep.equal(truncate1EnhancedObs);
60
+ });
61
+ it('1800 observations getUnitsSeries test', function() {
62
+ this.timeout(5000);
63
+ expect(getUnitsSeries(unitsObs)).to.deep.equal(unitsSeries);
64
+ })
65
+ });
@@ -1,145 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getSortedLayoutData = undefined;
7
-
8
- var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
9
-
10
- var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
11
-
12
- var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
13
-
14
- var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
15
-
16
- var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
17
-
18
- var _defineProperty3 = _interopRequireDefault(_defineProperty2);
19
-
20
- var _extends3 = require('babel-runtime/helpers/extends');
21
-
22
- var _extends4 = _interopRequireDefault(_extends3);
23
-
24
- var _ramda = require('ramda');
25
-
26
- var R = _interopRequireWildcard(_ramda);
27
-
28
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
29
-
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
- var getSublayoutIndexToPositionPivots = function getSublayoutIndexToPositionPivots(dimensions) {
33
- return R.map(function (dimension) {
34
- var indexedPositions = R.reduce( // => [(entryIndex) : { ...val, __index }] => { [__index]: entryIndex }
35
- function (acc, value) {
36
- return (0, _extends4.default)({}, acc, (0, _defineProperty3.default)({}, R.prop('__index', value), R.prop('__indexPosition', value)));
37
- }, {}, R.prop('values', dimension));
38
-
39
- return function (splitKey) {
40
- return R.pipe(R.nth(R.prop('__index', dimension)), function (index) {
41
- return R.prop(index, indexedPositions);
42
- })(splitKey);
43
- };
44
- }, dimensions);
45
- };
46
-
47
- var coordinatesToSublayoutData = function coordinatesToSublayoutData(sublayout, coordinates) {
48
- return R.addIndex(R.map)(function (valueIndex, dimensionIndex) {
49
- var sublayoutDimension = R.nth(dimensionIndex, sublayout);
50
- var value = R.find(R.propEq('__indexPosition', valueIndex), R.prop('values', sublayoutDimension));
51
- return {
52
- dimension: R.pick(['id', 'name', '__index'], sublayoutDimension),
53
- value: value
54
- };
55
- }, coordinates);
56
- };
57
-
58
- var getSortedLayoutData = exports.getSortedLayoutData = function getSortedLayoutData(layout, observations) {
59
- var headersPivots = getSublayoutIndexToPositionPivots(R.prop('header', layout));
60
- var rowsPivots = getSublayoutIndexToPositionPivots(R.prop('rows', layout));
61
- var sectionsPivots = getSublayoutIndexToPositionPivots(R.prop('sections', layout));
62
-
63
- var rowsSize = R.length(R.prop('rows', layout));
64
- var sectionsSize = R.length(R.prop('sections', layout));
65
-
66
- var sortedLayoutPositions = R.pipe(R.keys, R.map(function (key) {
67
- var splitKey = R.split(':', key);
68
- return R.converge(function () {
69
- for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) {
70
- rest[_key] = arguments[_key];
71
- }
72
-
73
- return rest;
74
- }, [].concat((0, _toConsumableArray3.default)(sectionsPivots), (0, _toConsumableArray3.default)(rowsPivots), (0, _toConsumableArray3.default)(headersPivots)))(splitKey);
75
- }), R.map(function (coordinates) {
76
- var _R$splitAt = R.splitAt(sectionsSize, coordinates),
77
- _R$splitAt2 = (0, _slicedToArray3.default)(_R$splitAt, 2),
78
- sections = _R$splitAt2[0],
79
- tail = _R$splitAt2[1];
80
-
81
- var _R$splitAt3 = R.splitAt(rowsSize, tail),
82
- _R$splitAt4 = (0, _slicedToArray3.default)(_R$splitAt3, 2),
83
- rows = _R$splitAt4[0],
84
- headers = _R$splitAt4[1];
85
-
86
- return { headers: headers, rows: rows, sections: sections };
87
- }))(observations);
88
-
89
- var headerData = R.pipe(R.pluck('headers'), R.uniq, R.map(function (coordinates) {
90
- return coordinatesToSublayoutData(R.prop('header', layout), coordinates);
91
- }), function (headerData) {
92
- if (R.isEmpty(headerData)) {
93
- return headerData;
94
- }
95
- var comparators = R.pipe(R.head, R.length, function (length) {
96
- return R.times(R.identity, length);
97
- }, R.map(function (index) {
98
- return R.ascend(R.pathOr(0, [index, 'value', '__indexPosition']));
99
- }))(headerData);
100
-
101
- return R.sortWith(comparators)(headerData);
102
- })(sortedLayoutPositions);
103
-
104
- var sectionsData = R.pipe(R.reduce(function (acc, layout) {
105
- var sections = layout.sections;
106
-
107
- var index = R.findIndex(R.pathEq([0, 'sections'], sections))(acc);
108
- if (index === -1) {
109
- return R.append([layout], acc);
110
- }
111
- return R.over(R.lensIndex(index), R.append(layout))(acc);
112
- }, []), R.map(function (entries) {
113
- var sectionData = coordinatesToSublayoutData(R.prop('sections', layout), R.prop('sections', R.head(entries)));
114
- var rowsData = R.map(function (coordinates) {
115
- return coordinatesToSublayoutData(R.prop('rows', layout), coordinates);
116
- }, R.uniq(R.pluck('rows', entries)));
117
- return [sectionData, rowsData];
118
- }), function (sData) {
119
- //sort sections
120
- if (R.isEmpty(sData) || R.isEmpty(R.head(R.head(sData)))) {
121
- return sData;
122
- }
123
- var comparators = R.pipe(R.head, R.head, R.length, function (length) {
124
- return R.times(R.identity, length);
125
- }, R.map(function (index) {
126
- return R.ascend(R.pathOr(0, [0, index, 'value', '__indexPosition']));
127
- }))(sData);
128
-
129
- return R.sortWith(comparators)(sData);
130
- }, function (sData) {
131
- //sort rows
132
- if (R.isEmpty(sData) || R.isEmpty(R.last(R.head(sData)))) {
133
- return sData;
134
- }
135
- var comparators = R.pipe(R.head, R.last, R.head, R.length, function (length) {
136
- return R.times(R.identity, length);
137
- }, R.map(function (index) {
138
- return R.ascend(R.pathOr(0, [index, 'value', '__indexPosition']));
139
- }))(sData);
140
-
141
- return R.map(R.over(R.lensIndex(1), R.sortWith(comparators)))(sData);
142
- })(sortedLayoutPositions);
143
-
144
- return { headerData: headerData, sectionsData: sectionsData };
145
- };