@sis-cc/dotstatsuite-components 15.0.21 → 16.0.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 (161) hide show
  1. package/lib/rules/src/index.js +1 -145
  2. package/lib/rules/src/table/index.js +0 -42
  3. package/lib/rules2/src/constants.js +3 -1
  4. package/lib/rules2/src/enhanceObservations.js +98 -0
  5. package/lib/rules2/src/getAttributesSeries.js +33 -0
  6. package/lib/rules2/src/getCombinationDefinitions.js +48 -0
  7. package/lib/rules2/src/getHeaderCombinations.js +42 -0
  8. package/lib/rules2/src/getHeaderSubtitle.js +41 -0
  9. package/lib/rules2/src/getManyValuesDimensions.js +39 -0
  10. package/lib/rules2/src/getOneValueDimensions.js +46 -0
  11. package/lib/rules2/src/hasCellMetadata.js +1 -1
  12. package/lib/rules2/src/index.js +186 -18
  13. package/lib/rules2/src/parseAttributes.js +50 -0
  14. package/lib/rules2/src/parseCombinations.js +54 -0
  15. package/lib/rules2/src/prepareData.js +74 -0
  16. package/lib/{rules/src/table/preparators/getAttributeValue.js → rules2/src/refineAttributes.js} +13 -11
  17. package/lib/rules2/src/table/getCells.js +74 -0
  18. package/lib/rules2/src/table/getCellsAttributesIds.js +63 -0
  19. package/lib/rules2/src/table/getCombinationDimensionsData.js +47 -0
  20. package/lib/rules2/src/table/getCuratedCells.js +28 -0
  21. package/lib/rules2/src/table/getFlagsAndNotes.js +28 -0
  22. package/lib/rules2/src/table/getIndexedCombinationsByDisplay.js +31 -0
  23. package/lib/rules2/src/table/getLayout.js +93 -0
  24. package/lib/rules2/src/table/getLayoutData.js +202 -0
  25. package/lib/{rules/src/table/factories → rules2/src/table}/getSortedLayoutIndexes.js +55 -40
  26. package/lib/rules2/src/table/getTableProps.js +64 -0
  27. package/lib/rules2/src/table/parseValueHierarchy.js +55 -0
  28. package/lib/{rules/src/table/factories → rules2/src/table}/refineLayoutSize.js +17 -8
  29. package/lib/rules2/src/{hasLayoutEntryMetadata.js → utils.js} +9 -6
  30. package/package.json +1 -1
  31. package/src/rules/src/index.js +1 -19
  32. package/src/rules/src/table/index.js +0 -4
  33. package/src/rules2/src/constants.js +2 -0
  34. package/src/rules2/src/enhanceObservations.js +88 -0
  35. package/src/rules2/src/getAttributesSeries.js +29 -0
  36. package/src/rules2/src/getCombinationDefinitions.js +29 -0
  37. package/src/rules2/src/getHeaderCombinations.js +39 -0
  38. package/src/rules2/src/getHeaderSubtitle.js +34 -0
  39. package/src/rules2/src/getManyValuesDimensions.js +34 -0
  40. package/src/rules2/src/getOneValueDimensions.js +33 -0
  41. package/src/rules2/src/hasCellMetadata.js +1 -1
  42. package/src/rules2/src/index.js +21 -6
  43. package/src/rules2/src/parseAttributes.js +36 -0
  44. package/src/rules2/src/parseCombinations.js +36 -0
  45. package/src/rules2/src/prepareData.js +50 -0
  46. package/src/rules2/src/refineAttributes.js +16 -0
  47. package/src/rules2/src/table/getCells.js +72 -0
  48. package/src/rules2/src/table/getCellsAttributesIds.js +38 -0
  49. package/src/rules2/src/table/getCombinationDimensionsData.js +38 -0
  50. package/src/rules2/src/table/getCuratedCells.js +33 -0
  51. package/src/rules2/src/table/getFlagsAndNotes.js +21 -0
  52. package/src/rules2/src/table/getIndexedCombinationsByDisplay.js +16 -0
  53. package/src/rules2/src/table/getLayout.js +80 -0
  54. package/src/rules2/src/table/getLayoutData.js +183 -0
  55. package/src/rules2/src/table/getSortedLayoutIndexes.js +119 -0
  56. package/src/rules2/src/table/getTableProps.js +36 -0
  57. package/src/rules2/src/table/parseValueHierarchy.js +27 -0
  58. package/src/{rules/src/table/factories → rules2/src/table}/refineLayoutSize.js +24 -8
  59. package/src/rules2/src/utils.js +12 -0
  60. package/test/enhanceObservations2.test.js +219 -0
  61. package/test/getAttributesSeries.test.js +58 -0
  62. package/test/getCells.test.js +6 -40
  63. package/test/getCombinationDimensionsData.test.js +48 -0
  64. package/test/getSortedLayoutIndexes.test.js +1025 -3
  65. package/test/parseAttributes.test.js +17 -62
  66. package/test/parseValueHierarchy.test.js +88 -0
  67. package/test/refineLayoutSize.test.js +2621 -1
  68. package/lib/rules/src/table/factories/getCells.js +0 -97
  69. package/lib/rules/src/table/factories/getConfirmedSeriesAttributesIds.js +0 -26
  70. package/lib/rules/src/table/factories/getCuratedCells.js +0 -45
  71. package/lib/rules/src/table/factories/getLayoutData.js +0 -168
  72. package/lib/rules/src/table/factories/getLayoutWithFlags.js +0 -133
  73. package/lib/rules/src/table/factories/getTableCells.js +0 -24
  74. package/lib/rules/src/table/factories/getTableData.js +0 -98
  75. package/lib/rules/src/table/preparators/getDimensionsAttributesRegisters.js +0 -43
  76. package/lib/rules/src/table/preparators/getManyValuesDimensions.js +0 -33
  77. package/lib/rules/src/table/preparators/getOneValueDimensions.js +0 -24
  78. package/lib/rules/src/table/preparators/getUniqValuesAttributes.js +0 -36
  79. package/lib/rules/src/table/preparators/parseAttributes.js +0 -84
  80. package/lib/rules/src/table/preparators/parseAttributesValuesFromObservations.js +0 -22
  81. package/lib/rules/src/table/preparators/parseDimensionsIds.js +0 -22
  82. package/lib/rules/src/table/preparators/prepareData.js +0 -191
  83. package/lib/rules/src/table/preparators/refineObservationsAttributesValues.js +0 -31
  84. package/lib/rules/src/table/preparators/refineSeriesAttributesValues.js +0 -23
  85. package/lib/rules/src/table/units/appendUnitsInLayoutData.js +0 -82
  86. package/lib/rules/src/table/units/appendUnitsInLayoutDataEntry.js +0 -45
  87. package/lib/rules/src/table/units/cleanUnitsInLayoutData.js +0 -66
  88. package/lib/rules/src/table/units/getAttachmentSeriesIndexes.js +0 -25
  89. package/lib/rules/src/table/units/getHeaderUnits.js +0 -35
  90. package/lib/rules/src/table/units/getUnitsArtefacts.js +0 -85
  91. package/lib/rules/src/table/units/getUnitsCodes.js +0 -23
  92. package/lib/rules/src/table/units/getUnitsDefinition.js +0 -33
  93. package/lib/rules/src/table/units/getUnitsDisplay.js +0 -33
  94. package/lib/rules/src/table/units/getUnitsSerieIndexes.js +0 -23
  95. package/lib/rules/src/table/units/getUnitsSeries.js +0 -49
  96. package/lib/rules/src/table/units/getUnitsinLayout.js +0 -74
  97. package/lib/rules/src/table/units/refineDimSeriesUnits.js +0 -44
  98. package/lib/rules2/src/getAdvancedAttributes.js +0 -124
  99. package/lib/rules2/src/invertTime.js +0 -33
  100. package/src/rules/src/table/factories/getCells.js +0 -102
  101. package/src/rules/src/table/factories/getConfirmedSeriesAttributesIds.js +0 -27
  102. package/src/rules/src/table/factories/getCuratedCells.js +0 -40
  103. package/src/rules/src/table/factories/getLayoutData.js +0 -171
  104. package/src/rules/src/table/factories/getLayoutWithFlags.js +0 -137
  105. package/src/rules/src/table/factories/getSortedLayoutIndexes.js +0 -108
  106. package/src/rules/src/table/factories/getTableCells.js +0 -16
  107. package/src/rules/src/table/factories/getTableData.js +0 -86
  108. package/src/rules/src/table/preparators/getAttributeValue.js +0 -17
  109. package/src/rules/src/table/preparators/getDimensionsAttributesRegisters.js +0 -51
  110. package/src/rules/src/table/preparators/getManyValuesDimensions.js +0 -19
  111. package/src/rules/src/table/preparators/getOneValueDimensions.js +0 -17
  112. package/src/rules/src/table/preparators/getUniqValuesAttributes.js +0 -24
  113. package/src/rules/src/table/preparators/parseAttributes.js +0 -113
  114. package/src/rules/src/table/preparators/parseAttributesValuesFromObservations.js +0 -16
  115. package/src/rules/src/table/preparators/parseDimensionsIds.js +0 -17
  116. package/src/rules/src/table/preparators/prepareData.js +0 -197
  117. package/src/rules/src/table/preparators/refineObservationsAttributesValues.js +0 -22
  118. package/src/rules/src/table/preparators/refineSeriesAttributesValues.js +0 -11
  119. package/src/rules/src/table/units/appendUnitsInLayoutData.js +0 -56
  120. package/src/rules/src/table/units/appendUnitsInLayoutDataEntry.js +0 -38
  121. package/src/rules/src/table/units/cleanUnitsInLayoutData.js +0 -65
  122. package/src/rules/src/table/units/getAttachmentSeriesIndexes.js +0 -27
  123. package/src/rules/src/table/units/getHeaderUnits.js +0 -32
  124. package/src/rules/src/table/units/getUnitsArtefacts.js +0 -90
  125. package/src/rules/src/table/units/getUnitsCodes.js +0 -22
  126. package/src/rules/src/table/units/getUnitsDefinition.js +0 -34
  127. package/src/rules/src/table/units/getUnitsDisplay.js +0 -19
  128. package/src/rules/src/table/units/getUnitsSerieIndexes.js +0 -12
  129. package/src/rules/src/table/units/getUnitsSeries.js +0 -41
  130. package/src/rules/src/table/units/getUnitsinLayout.js +0 -71
  131. package/src/rules/src/table/units/refineDimSeriesUnits.js +0 -26
  132. package/src/rules2/src/getAdvancedAttributes.js +0 -111
  133. package/src/rules2/src/hasLayoutEntryMetadata.js +0 -9
  134. package/src/rules2/src/invertTime.js +0 -22
  135. package/test/advanced-attributes-parsing-perf.test.js +0 -16
  136. package/test/appendUnitsInLayoutDataEntry.test.js +0 -65
  137. package/test/cleanUnitsInLayoutData.test.js +0 -85
  138. package/test/enhanceObservations.test.js +0 -340
  139. package/test/getAttachmentSeriesIndexes.test.js +0 -35
  140. package/test/getConfirmedSeriesAttributesIds.test.js +0 -27
  141. package/test/getDataflowAdvancedAttributes.test.js +0 -32
  142. package/test/getHeaderUnits.test.js +0 -51
  143. package/test/getLayoutData.test.js +0 -206
  144. package/test/getLayoutDataWithFlags.test.js +0 -142
  145. package/test/getOneValueDimensions.test.js +0 -26
  146. package/test/getSeriesAdvancedAttributes.test.js +0 -32
  147. package/test/getSubtitleFlags.test.js +0 -42
  148. package/test/getTableData.test.js +0 -1317
  149. package/test/getUnitsArtefacts.test.js +0 -117
  150. package/test/getUnitsDefinition.test.js +0 -37
  151. package/test/getUnitsInLayout.test.js +0 -77
  152. package/test/getUnitsSeries.test.js +0 -154
  153. package/test/invertTime.test.js +0 -77
  154. package/test/parseAttributesValuesFromObservations.test.js +0 -45
  155. package/test/parseDimensionsIds.test.js +0 -20
  156. package/test/prepareData.test.js +0 -29
  157. package/test/refineObservationsAttributesValues.test.js +0 -33
  158. package/test/table-invert-time-perf.test.js +0 -11
  159. package/test/table-layout-perf.test.js +0 -74
  160. package/test/table-prep-duplicate-perf.test.js +0 -15
  161. package/test/table-prep-perf.test.js +0 -61
@@ -1,5 +1,14 @@
1
1
  import * as R from 'ramda';
2
2
 
3
+ const toKey = indexes => R.reduce(
4
+ (acc, _ind) => {
5
+ const ind = R.is(Array, _ind) ? toKey(_ind) : Math.abs(_ind);
6
+ return R.isEmpty(acc) ? String(ind) : `${acc}:${ind}`
7
+ },
8
+ '',
9
+ indexes
10
+ );
11
+
3
12
  const getPivotKey = indexes => R.pipe(
4
13
  R.props(indexes),
5
14
  R.join(':')
@@ -7,7 +16,13 @@ const getPivotKey = indexes => R.pipe(
7
16
 
8
17
  const getPivots = (layout, shape) => R.pipe(
9
18
  R.props(shape),
10
- R.map(R.pipe(R.pluck('__index'), getPivotKey))
19
+ R.map(
20
+ R.pipe(
21
+ R.map(entry => R.has('dimensions', entry) ? R.pluck('__index', entry.dimensions || []) : entry.__index),
22
+ R.unnest,
23
+ getPivotKey
24
+ )
25
+ )
11
26
  )(layout);
12
27
 
13
28
  const indexWithPivots = (pivots, observations) => R.pipe(
@@ -35,12 +50,12 @@ export const getCuratedCells = ({ layout, observations, shape }) => {
35
50
  export const refineSections = (sections, extractedKeys, curatedObs) => R.pipe(
36
51
  R.map(
37
52
  (section) => {
38
- const sectionKey = R.join(':', R.head(section) || []);
53
+ const sectionKey = toKey(R.head(section) || []);
39
54
  return R.over(
40
55
  R.lensIndex(1),
41
56
  R.filter(
42
57
  rowData => {
43
- const rowKey = R.join(':', rowData);
58
+ const rowKey = toKey(rowData);
44
59
  return R.pipe(
45
60
  R.path([sectionKey, rowKey]),
46
61
  R.omit(extractedKeys),
@@ -59,7 +74,7 @@ export const refineSections = (sections, extractedKeys, curatedObs) => R.pipe(
59
74
 
60
75
  export const refineHeader = (header, extractedKeys, curatedObs) => R.filter( // extracted : { [sectionKey]: [...rowKeys] }
61
76
  (header) => {
62
- const headerKey = R.join(':', header);
77
+ const headerKey = toKey(header);
63
78
  return R.pipe(
64
79
  R.prop(headerKey),
65
80
  (sections) => {
@@ -86,17 +101,17 @@ export const truncateSectionRows = (n, sectionsData) => {
86
101
  const lastSection = R.last(truncated);
87
102
  const rows = lastSection[1];
88
103
  const rowsLength = R.length(rows);
89
- const sectionKey = R.join(':', R.head(lastSection));
104
+ const sectionKey = toKey(R.head(lastSection));
90
105
  if (rowsLength > _n) {
91
106
  const [rest, extracted] = R.splitAt(R.negate(_n), rows);
92
107
  const updatedSection = R.set(R.lensIndex(1), rest)(lastSection);
93
108
  truncated = R.set(R.lensIndex(-1), updatedSection)(truncated);
94
- extractedKeys = { ...extractedKeys, [sectionKey]: R.map(R.join(':'), extracted) };
109
+ extractedKeys = { ...extractedKeys, [sectionKey]: R.map(toKey, extracted) };
95
110
  _n = 0;
96
111
  }
97
112
  else {
98
113
  truncated = R.dropLast(1, truncated);
99
- extractedKeys = { ...extractedKeys, [sectionKey]: R.map(R.join(':'), rows) };
114
+ extractedKeys = { ...extractedKeys, [sectionKey]: R.map(toKey, rows) };
100
115
  _n = _n - rowsLength;
101
116
  }
102
117
  }
@@ -105,7 +120,7 @@ export const truncateSectionRows = (n, sectionsData) => {
105
120
 
106
121
  export const truncateHeader = (n, headerData) => {
107
122
  const [truncated, extracted] = R.splitAt(R.negate(n))(headerData);
108
- return ({ truncated, extractedKeys: R.map(R.join(':'), extracted) });
123
+ return ({ truncated, extractedKeys: R.map(toKey, extracted) });
109
124
  };
110
125
 
111
126
  const truncateLayout = (isVertical) => R.ifElse(
@@ -218,6 +233,7 @@ export const refineLayoutSize = ({ layout, observations, limit }) => layoutIndex
218
233
  (shape) => getCuratedCells({ layout, observations, shape })
219
234
  )(isVertical);
220
235
 
236
+
221
237
  const refined = refineLayout(isVertical)(toRefine, extractedKeys, curatedObs);
222
238
 
223
239
  const result = getRefinedLayout(isVertical, truncated, refined);
@@ -0,0 +1,12 @@
1
+ import * as R from 'ramda';
2
+
3
+ export const trimedProps = (properties, obj) => R.reduce(
4
+ (acc, prop) => {
5
+ if (!R.has(prop, obj)) {
6
+ return acc;
7
+ }
8
+ return R.append(obj[prop], acc);
9
+ },
10
+ [],
11
+ properties,
12
+ );
@@ -0,0 +1,219 @@
1
+ import { expect } from 'chai';
2
+ import { enhanceObservations } from '../src/rules2/src/enhanceObservations';
3
+ import numeral from 'numeral';
4
+
5
+ numeral.register('locale', 'eObs', { delimiters: { thousands: ",", decimal: "." } });
6
+ describe('enhanceObservations tests', () => {
7
+ it('blank test', () => {
8
+ expect(enhanceObservations([], {}, [], {})).to.deep.equal({});
9
+ });
10
+ it('formatValue test', () => {
11
+ numeral.locale('eObs');
12
+ const attributes = [
13
+ { id: 'A1', values: [] },
14
+ { id: 'A2', values: [{ id: '-1' }, { id: '0' }, { id: '1' }, { id: '3' }, { id: 'Z' }] },
15
+ { id: 'A3', values: [{ id: '0' }, { id: '2' }, { id: '3' }, { id: '5' }, { id: 'A' }] }
16
+ ];
17
+
18
+ const customAttributes = { prefscale: 'A2', decimals: 'A3' };
19
+
20
+ const observations = {
21
+ a: { value: 2, attrValuesIndexes: [null, null, null], dimValuesIndexes: [] },
22
+ c: { value: 10, attrValuesIndexes: [null, 4, null], dimValuesIndexes: [] },
23
+ d: { value: 5, attrValuesIndexes: [null, 1, null], dimValuesIndexes: [] },
24
+ e: { value: 8.3, attrValuesIndexes: [null, 0, null], dimValuesIndexes: [] },
25
+ f: { value: 25.62, attrValuesIndexes: [null, 3, null], dimValuesIndexes: [] },
26
+ g: { value: 3.7, attrValuesIndexes: [null, null, 4], dimValuesIndexes: [] },
27
+ h: { value: 21.1234567, attrValuesIndexes: [null, null, 2], dimValuesIndexes: [] },
28
+ i: { value: 20.1, attrValuesIndexes: [null, null, 3], dimValuesIndexes: [] },
29
+ j: { value: 19.9, attrValuesIndexes: [null, null, 0], dimValuesIndexes: [] },
30
+ k: { value: 16.35, attrValuesIndexes: [null, 2, 1], dimValuesIndexes: [] },
31
+ l: { value: 155062.56, attrValuesIndexes: [null, null, 2], dimValuesIndexes: [] },
32
+ m: { value: 155062.56, attrValuesIndexes: [null, null, 0], dimValuesIndexes: [] },
33
+ n: { value: null, attrValuesIndexes: [null, null, 1], dimValuesIndexes: [] },
34
+ };
35
+
36
+ expect(enhanceObservations([], observations, attributes, { customAttributes })).to.deep.equal({
37
+ a: { attributes: {}, value: 2, formattedValue: '2', attrValuesIndexes: [null, null, null], dimValuesIndexes: [], indexedDimValIds: {} },
38
+ c: { attributes: {}, value: 10, formattedValue: '10', attrValuesIndexes: [null, 4, null], dimValuesIndexes: [], indexedDimValIds: {} },
39
+ d: { attributes: {}, value: 5, formattedValue: '5', attrValuesIndexes: [null, 1, null], dimValuesIndexes: [], indexedDimValIds: {} },
40
+ e: { attributes: {}, value: 8.3, formattedValue: '83', attrValuesIndexes: [null, 0, null], dimValuesIndexes: [], indexedDimValIds: {} },
41
+ f: { attributes: {}, value: 25.62, formattedValue: '0.02562', attrValuesIndexes: [null, 3, null], dimValuesIndexes: [], indexedDimValIds: {} },
42
+ g: { attributes: {}, value: 3.7, formattedValue: '3.7', attrValuesIndexes: [null, null, 4], dimValuesIndexes: [], indexedDimValIds: {} },
43
+ h: { attributes: {}, value: 21.1234567, formattedValue: '21.123', attrValuesIndexes: [null, null, 2], dimValuesIndexes: [], indexedDimValIds: {} },
44
+ i: { attributes: {}, value: 20.1, formattedValue: '20.10000', attrValuesIndexes: [null, null, 3], dimValuesIndexes: [], indexedDimValIds: {} },
45
+ j: { attributes: {}, value: 19.9, formattedValue: '20', attrValuesIndexes: [null, null, 0], dimValuesIndexes: [], indexedDimValIds: {} },
46
+ k: { attributes: {}, value: 16.35, formattedValue: '1.64', attrValuesIndexes: [null, 2, 1], dimValuesIndexes: [], indexedDimValIds: {} },
47
+ l: { attributes: {}, value: 155062.56, formattedValue: '155,062.560', attrValuesIndexes: [null, null, 2], dimValuesIndexes: [], indexedDimValIds: {} },
48
+ m: { attributes: {}, value: 155062.56, formattedValue: '155,063', attrValuesIndexes: [null, null, 0], dimValuesIndexes: [], indexedDimValIds: {} },
49
+ n: { attributes: {}, value: null, formattedValue: '..', attrValuesIndexes: [null, null, 1], dimValuesIndexes: [], indexedDimValIds: {} },
50
+ });
51
+ });
52
+ it('attributes', () => {
53
+ const attributes = [
54
+ {
55
+ id: 'a0',
56
+ values: [{ id: 'v0' }, { id: 'v1' }, { id: 'v2' }],
57
+ relationship: ['d0', 'd1'],
58
+ series: true
59
+ },
60
+ {
61
+ id: 'a1',
62
+ values: [{ id: 'v0' }],
63
+ },
64
+ {
65
+ id: 'a2',
66
+ values: [{ id: 'v0' }, { id: 'v1' }],
67
+ relationship: []
68
+ },
69
+ {
70
+ id: 'a3',
71
+ values: [{ id: 'v0' }, { id: 'v1' }],
72
+ relationship: ['d2', 'd3'],
73
+ series: true
74
+ },
75
+ {
76
+ id: 'a4',
77
+ values: [{ id: 'v0' }, { id: 'v1', display: false }],
78
+ relationship: ['d4'],
79
+ series: true
80
+ },
81
+ ];
82
+
83
+ const dimensions = [
84
+ {
85
+ id: 'd0',
86
+ __index: 0,
87
+ values: [
88
+ { id: 'v0', __index: 0, __indexPosition: 0 },
89
+ { id: 'v1', __index: 1, __indexPosition: 1 },
90
+ { id: 'v2', __index: 2, __indexPosition: 2 },
91
+ { id: 'v3', __index: 3, __indexPosition: 3, display: false }
92
+ ]
93
+ },
94
+ {
95
+ id: 'd1',
96
+ __index: 1,
97
+ values: [
98
+ { id: 'v0', __index: 0, __indexPosition: 0 }
99
+ ]
100
+ },
101
+ {
102
+ id: 'd2',
103
+ __index: 2,
104
+ values: [
105
+ { id: 'v0', __index: 0, __indexPosition: 0 }
106
+ ]
107
+ },
108
+ {
109
+ id: 'd3',
110
+ __index: 3,
111
+ values: [
112
+ { id: 'v0', __index: 0, __indexPosition: 0 },
113
+ { id: 'v1', __index: 1, __indexPosition: 1 }
114
+ ]
115
+ },
116
+ {
117
+ id: 'd4',
118
+ __index: 4,
119
+ values: [
120
+ { id: 'v0', __index: 0, __indexPosition: 0 }
121
+ ]
122
+ }
123
+ ];
124
+
125
+
126
+ const observations = {
127
+ a: {
128
+ attrValuesIndexes: [0, 0, 0, 0, 0],
129
+ dimValuesIndexes: [0, 0, 0, 0, 0],
130
+ value: 22,
131
+ },
132
+ b: {
133
+ attrValuesIndexes: [1, 0, 1, 1, 0],
134
+ dimValuesIndexes: [0, 0, 0, 1, 0],
135
+ value: 17,
136
+ },
137
+ c: {
138
+ attrValuesIndexes: [2, 0, null, null, 0],
139
+ dimValuesIndexes: [1, 0, 0, 0, 0],
140
+ value: 55,
141
+ },
142
+ d: {
143
+ attrValuesIndexes: [2, 0, null, null, null],
144
+ dimValuesIndexes: [2, 0, 0, 0, 0],
145
+ value: 35,
146
+ },
147
+ e: {
148
+ attrValuesIndexes: [2, null, null, null, null],
149
+ dimValuesIndexes: [3, 0, 0, 0, 0],
150
+ value: 35,
151
+ }
152
+ };
153
+
154
+
155
+ expect(enhanceObservations(dimensions, observations, attributes, {})).to.deep.equal({
156
+ a: {
157
+ attrValuesIndexes: [0, 0, 0, 0, 0],
158
+ dimValuesIndexes: [0, 0, 0, 0, 0],
159
+ value: 22,
160
+ formattedValue: '22',
161
+ attributes: {
162
+ a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v0' }, serieKey: 'd0=v0:d1=v0', coordinates: { d0: 'v0', d1: 'v0' }, isObs: false },
163
+ a3: { id: 'a3', relationship: ['d2', 'd3'], value: { id: 'v0' }, serieKey: 'd2=v0:d3=v0', coordinates: { d2: 'v0', d3: 'v0' }, isObs: false },
164
+ a4: { id: 'a4', relationship: ['d4'], value: { id: 'v0' }, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
165
+ },
166
+ indexedDimValIds: { d0: 'v0', d1: 'v0', d2: 'v0', d3: 'v0', d4: 'v0' }
167
+ },
168
+ b: {
169
+ attrValuesIndexes: [1, 0, 1, 1, 0],
170
+ dimValuesIndexes: [0, 0, 0, 1, 0],
171
+ value: 17,
172
+ formattedValue: '17',
173
+ attributes: {
174
+ a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v1' }, serieKey: 'd0=v0:d1=v0', coordinates: { d0: 'v0', d1: 'v0' }, isObs: false },
175
+ a3: { id: 'a3', relationship: ['d2', 'd3'], value: { id: 'v1' }, serieKey: 'd2=v0:d3=v1', coordinates: { d2: 'v0', d3: 'v1' }, isObs: false },
176
+ a4: { id: 'a4', relationship: ['d4'], value: { id: 'v0' }, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
177
+ },
178
+ indexedDimValIds: { d0: 'v0', d1: 'v0', d2: 'v0', d3: 'v1', d4: 'v0' }
179
+ },
180
+ c: {
181
+ attrValuesIndexes: [2, 0, null, null, 0],
182
+ dimValuesIndexes: [1, 0, 0, 0, 0],
183
+ value: 55,
184
+ formattedValue: '55',
185
+ attributes: {
186
+ a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v2' }, serieKey: 'd0=v1:d1=v0', coordinates: { d0: 'v1', d1: 'v0' }, isObs: false },
187
+ a3: { id: 'a3', relationship: ['d2', 'd3'], value: undefined, serieKey: 'd2=v0:d3=v0', coordinates: { d2: 'v0', d3: 'v0' }, isObs: false },
188
+ a4: { id: 'a4', relationship: ['d4'], value: { id: 'v0' }, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
189
+ },
190
+ indexedDimValIds: { d0: 'v1', d1: 'v0', d2: 'v0', d3: 'v0', d4: 'v0' }
191
+ },
192
+ d: {
193
+ attrValuesIndexes: [2, 0, null, null, null],
194
+ dimValuesIndexes: [2, 0, 0, 0, 0],
195
+ value: 35,
196
+ formattedValue: '35',
197
+ attributes: {
198
+ a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v2' }, serieKey: 'd0=v2:d1=v0', coordinates: { d0: 'v2', d1: 'v0' }, isObs: false },
199
+ a3: { id: 'a3', relationship: ['d2', 'd3'], value: undefined, serieKey: 'd2=v0:d3=v0', coordinates: { d2: 'v0', d3: 'v0' }, isObs: false },
200
+ a4: { id: 'a4', relationship: ['d4'], value: undefined, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
201
+ },
202
+ indexedDimValIds: { d0: 'v2', d1: 'v0', d2: 'v0', d3: 'v0', d4: 'v0' }
203
+ },
204
+ e: {
205
+ attrValuesIndexes: [2, null, null, null, null],
206
+ dimValuesIndexes: [3, 0, 0, 0, 0],
207
+ value: 35,
208
+ formattedValue: '35',
209
+ attributes: {
210
+ a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v2' }, serieKey: 'd0=v3:d1=v0', coordinates: { d0: 'v3', d1: 'v0' }, isObs: false },
211
+ a3: { id: 'a3', relationship: ['d2', 'd3'], value: undefined, serieKey: 'd2=v0:d3=v0', coordinates: { d2: 'v0', d3: 'v0' }, isObs: false },
212
+ a4: { id: 'a4', relationship: ['d4'], value: undefined, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
213
+ },
214
+ indexedDimValIds: { d0: 'v3', d1: 'v0', d2: 'v0', d3: 'v0', d4: 'v0' }
215
+ }
216
+ });
217
+ });
218
+ });
219
+
@@ -0,0 +1,58 @@
1
+ import { expect } from 'chai';
2
+ import { getAttributesSeries } from '../src/rules2/src/getAttributesSeries';
3
+
4
+ describe('getAttributesSeries tests', () => {
5
+ it('complete case', () => {
6
+ const observations = {
7
+ a: {
8
+ attributes: {
9
+ A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
10
+ B: { id: 'B', value: { id: 'B0' }, serieKey: 'd1=v0' },
11
+ }
12
+ },
13
+ b: {
14
+ attributes: {
15
+ A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
16
+ B: { id: 'B', value: { id: 'B1' }, serieKey: 'd1=v0' },
17
+ }
18
+ },
19
+ c: {
20
+ attributes: {
21
+ A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
22
+ B: { id: 'B', value: { id: 'B1' }, serieKey: 'd1=v1' },
23
+ }
24
+ },
25
+ d: {
26
+ attributes: {
27
+ A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
28
+ B: { id: 'B', value: { id: 'B1' }, serieKey: 'd1=v1' },
29
+ }
30
+ },
31
+ e: {
32
+ attributes: {
33
+ A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
34
+ B: { id: 'B', value: { id: 'B3' }, serieKey: 'd1=v2' },
35
+ }
36
+ },
37
+ f: {
38
+ attributes: {
39
+ A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
40
+ B: { id: 'B', value: { id: 'B3' }, serieKey: 'd1=v2' },
41
+ }
42
+ }
43
+ };
44
+
45
+ expect(getAttributesSeries(observations)).to.deep.equal({
46
+ 'd0=v0': {
47
+ A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
48
+ },
49
+ 'd1=v0': {},
50
+ 'd1=v1': {
51
+ B: { id: 'B', value: { id: 'B1' }, serieKey: 'd1=v1' },
52
+ },
53
+ 'd1=v2': {
54
+ B: { id: 'B', value: { id: 'B3' }, serieKey: 'd1=v2' },
55
+ }
56
+ })
57
+ });
58
+ });
@@ -1,7 +1,5 @@
1
1
  import { expect } from 'chai';
2
- import { getCells } from '../src/rules/src/table/factories/getCells';
3
- import { OBS_TYPE_NUMERICAL_STRING } from '../src/rules/src/constants';
4
- import * as R from 'ramda';
2
+ import { getCells } from '../src/rules2/src/';
5
3
 
6
4
  const customAttributes = {
7
5
  flags: ['FL1', 'FL2'],
@@ -9,9 +7,8 @@ const customAttributes = {
9
7
  };
10
8
 
11
9
  describe('getCells tests', () => {
12
- it('flags display name', () => {
13
- expect(getCells({
14
- observations: {
10
+ it('flags', () => {
11
+ expect(getCells(customAttributes, ['FL1', 'FL2', 'FT1', 'FT2', 'FT3'], [], {}, {})({
15
12
  a: {
16
13
  key: 'a',
17
14
  value: 33,
@@ -23,7 +20,6 @@ describe('getCells tests', () => {
23
20
  },
24
21
  indexedDimValIds: {}
25
22
  }
26
- }
27
23
  }, 'label', customAttributes,
28
24
  { unitsDefinitionCodes: [], unitsSeries: {}, unitsDisplay: 'cells', unitDimension: {} }, [])).to.deep.equal({
29
25
  a: {
@@ -31,39 +27,9 @@ describe('getCells tests', () => {
31
27
  value: '33',
32
28
  intValue: 33,
33
29
  flags: [
34
- { code: 'FL2.1', label: 'Flag 2: Flag 2 Value 1' },
35
- { label: 'Footnote 1: Footnote 1 Value 1' },
36
- { label: 'Footnote 3: Footnote 3 Value 3' }
37
- ],
38
- indexedDimValIds: {},
39
- sideProps: null
40
- }
41
- })
42
- });
43
- it('flags display both', () => {
44
- expect(getCells({
45
- observations: {
46
- a: {
47
- key: 'a',
48
- value: 33,
49
- formattedValue: '33',
50
- attributes: {
51
- FL2: { id: 'FL2', name: 'Flag 2', value: { id: 'FL2.1', name: 'Flag 2 Value 1' } },
52
- FT1: { id: 'FT1', name: 'Footnote 1', value: { id: 'FT1.1', name: 'Footnote 1 Value 1' } },
53
- FT3: { id: 'FT3', name: 'Footnote 3', value: { id: 'FT3.3', name: 'Footnote 3 Value 3' } },
54
- },
55
- indexedDimValIds: {},
56
- }
57
- }
58
- }, 'both', customAttributes, {}, [])).to.deep.equal({
59
- a: {
60
- key: 'a',
61
- value: '33',
62
- intValue: 33,
63
- flags: [
64
- { code: 'FL2.1', label: '(FL2) Flag 2: (FL2.1) Flag 2 Value 1' },
65
- { label: '(FT1) Footnote 1: (FT1.1) Footnote 1 Value 1' },
66
- { label: '(FT3) Footnote 3: (FT3.3) Footnote 3 Value 3' }
30
+ { code: 'FL2.1', id: 'FL2', name: 'Flag 2', value: { id: 'FL2.1', name: 'Flag 2 Value 1' } },
31
+ { id: 'FT1', name: 'Footnote 1', value: { id: 'FT1.1', name: 'Footnote 1 Value 1' } },
32
+ { id: 'FT3', name: 'Footnote 3', value: { id: 'FT3.3', name: 'Footnote 3 Value 3' } }
67
33
  ],
68
34
  indexedDimValIds: {},
69
35
  sideProps: null
@@ -0,0 +1,48 @@
1
+ import { expect } from 'chai';
2
+ import { getCombinationDimensionsData } from '../src/rules2/src/table/getCombinationDimensionsData';
3
+
4
+ describe('getCombinationDimensionsData', () => {
5
+ it('basic test', () => {
6
+ const combination = {
7
+ id: 'COMB',
8
+ dimensions: [
9
+ {
10
+ id: 'D0',
11
+ values: [
12
+ { id: 'v0' },
13
+ { id: 'v1' },
14
+ { id: 'v2' },
15
+ ]
16
+ },
17
+ {
18
+ id: 'D1',
19
+ values: [
20
+ { id: 'v0' },
21
+ { id: 'v1', hasAdvancedAttributes: true },
22
+ { id: 'v2' },
23
+ ]
24
+ },
25
+ {
26
+ id: 'D2',
27
+ values: [
28
+ { id: 'v0' },
29
+ { id: 'v1' },
30
+ { id: 'v2' },
31
+ ]
32
+ }
33
+ ]
34
+ };
35
+
36
+ const indexes = [0, 1, -2];
37
+
38
+ const previous = { D0: { id: 'v0' }, D1: { id: 'v0' }, D2: { id: 'v2' } };
39
+
40
+ expect(getCombinationDimensionsData(indexes, combination, previous, true)).to.deep.equal({
41
+ dimValues: { D0: { id: 'v0' }, D1: { id: 'v1', hasAdvancedAttributes: true }, D2: { id: 'v2' } },
42
+ sameSerie: false,
43
+ coordinates: { D0: 'v0', D1: 'v1', D2: 'v2' },
44
+ ids: ['D0=v0', 'D1=v1', 'D2=v2'],
45
+ hasAdvancedAttributes: true
46
+ });
47
+ });
48
+ });