|
|
@@ -206,11 +206,10 @@ const formatJcEvents = (events) => {
|
|
|
}
|
|
|
|
|
|
if (!eventsMap[ratioKey]) {
|
|
|
- eventsMap[ratioKey] = [];
|
|
|
+ eventsMap[ratioKey] = new Array(3).fill(undefined);
|
|
|
}
|
|
|
|
|
|
const value = events[key] ?? 0;
|
|
|
-
|
|
|
eventsMap[ratioKey][index] = { key, value };
|
|
|
|
|
|
});
|
|
|
@@ -219,59 +218,59 @@ const formatJcEvents = (events) => {
|
|
|
}).filter(item => item.length == 4 && !item.some(v => !v));
|
|
|
}
|
|
|
|
|
|
-const rivalIor = (ior) => {
|
|
|
- const map = {
|
|
|
- "ior_rh": "ior_rac",
|
|
|
- "ior_rc": "ior_rah",
|
|
|
- "ior_rac": "ior_rh",
|
|
|
- "ior_rah": "ior_rc",
|
|
|
- "ior_ouc": "ior_ouh",
|
|
|
- "ior_ouh": "ior_ouc",
|
|
|
- };
|
|
|
- const iorInfos = ior.split('_');
|
|
|
- const iorStart = iorInfos.slice(0, 2).join('_');
|
|
|
- if (!map[iorStart]) {
|
|
|
- return ior;
|
|
|
- }
|
|
|
- return `${map[iorStart]}_${iorInfos[2]}`;
|
|
|
-}
|
|
|
+// const rivalIor = (ior) => {
|
|
|
+// const map = {
|
|
|
+// "ior_rh": "ior_rac",
|
|
|
+// "ior_rc": "ior_rah",
|
|
|
+// "ior_rac": "ior_rh",
|
|
|
+// "ior_rah": "ior_rc",
|
|
|
+// "ior_wmh": "ior_wmc",
|
|
|
+// "ior_wmc": "ior_wmh",
|
|
|
+// "ior_wmh_2": "ior_wmc_2",
|
|
|
+// "ior_wmc_2": "ior_wmh_2"
|
|
|
+// };
|
|
|
+// const iorInfos = ior.split('_');
|
|
|
+// const iorStart = iorInfos.slice(0, 2).join('_');
|
|
|
+// if (!map[iorStart]) {
|
|
|
+// return ior;
|
|
|
+// }
|
|
|
+// return `${map[iorStart]}_${iorInfos[2]}`;
|
|
|
+// }
|
|
|
|
|
|
const formatEvents = (events, cprKeys) => {
|
|
|
const eventsMap = {};
|
|
|
- cprKeys.forEach(key => {
|
|
|
+ Object.keys(events).forEach(key => {
|
|
|
const { type, side, ratio } = parseIorKey(key);
|
|
|
- let ratioKey, values = [];
|
|
|
+ let ratioKey, index;
|
|
|
if (type === 'r') {
|
|
|
if (side === 'h') {
|
|
|
ratioKey = ratio;
|
|
|
- values[0] = { key, value: events[key] ?? 0 };
|
|
|
- values[2] = { key: rivalIor(key), value: events[rivalIor(key)] ?? 0 };
|
|
|
+ index = 0;
|
|
|
}
|
|
|
else if (side === 'c') {
|
|
|
ratioKey = -ratio;
|
|
|
- values[0] = { key: rivalIor(key), value: events[rivalIor(key)] ?? 0 };
|
|
|
- values[2] = { key, value: events[key] ?? 0 };
|
|
|
+ index = 2;
|
|
|
}
|
|
|
- values[1] = { key: '', value: 0 };
|
|
|
}
|
|
|
else if (type === 'm') {
|
|
|
ratioKey = 'm';
|
|
|
- if (side == 'n') {
|
|
|
- values[0] = { key: 'ior_mh', value: events['ior_mh'] ?? 0 };
|
|
|
- values[1] = { key: 'ior_mn', value: events['ior_mn'] ?? 0 };
|
|
|
- values[2] = { key: 'ior_mc', value: events['ior_mc'] ?? 0 };
|
|
|
+ if (side == 'h') {
|
|
|
+ index = 0;
|
|
|
+ }
|
|
|
+ else if (side == 'c') {
|
|
|
+ index = 2;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ index = 1;
|
|
|
}
|
|
|
}
|
|
|
else if (type === 'wm') {
|
|
|
ratioKey = `wm_${Math.abs(ratio)}`;
|
|
|
- values[0] = { key: '', value: 0 };
|
|
|
- values[1] = { key: '', value: 0 };
|
|
|
- values[2] = { key: '', value: 0 };
|
|
|
if (side === 'h') {
|
|
|
- values[0] = { key, value: events[key] ?? 0 };
|
|
|
+ index = 0;
|
|
|
}
|
|
|
else if (side === 'c') {
|
|
|
- values[2] = { key, value: events[key] ?? 0 };
|
|
|
+ index = 2;
|
|
|
}
|
|
|
}
|
|
|
if (typeof (ratioKey) == 'number') {
|
|
|
@@ -285,8 +284,15 @@ const formatEvents = (events, cprKeys) => {
|
|
|
ratioKey = `${ratioKey}`;
|
|
|
}
|
|
|
}
|
|
|
- eventsMap[ratioKey] = values;
|
|
|
+
|
|
|
+ if (!eventsMap[ratioKey]) {
|
|
|
+ eventsMap[ratioKey] = new Array(3).fill(undefined);
|
|
|
+ }
|
|
|
+
|
|
|
+ const value = events[key] ?? 0;
|
|
|
+ eventsMap[ratioKey][index] = { key, value };
|
|
|
});
|
|
|
+ console.log('eventsMap', eventsMap);
|
|
|
return Object.keys(eventsMap).sort((a, b) => a.localeCompare(b)).map(key => {
|
|
|
return [key, ...eventsMap[key]];
|
|
|
});
|