fix: /stats now uses double hyphens like /today for WN8

This commit is contained in:
TresAbhi committed 2023-06-03 01:29:42 +00:00
1 parent 84056d7036
commit 843cc8e861
3 files changed
+13 -3

No files matched your search

+5
View File
@@ -78,6 +78,8 @@ export default {
0, 0,
); );
let hasWN8AccumulatedAtAll = false;
supplementaryStats = { supplementaryStats = {
tier: tier:
entries.reduce((accumulator, [tankIdString, stats]) => { entries.reduce((accumulator, [tankIdString, stats]) => {
@@ -93,11 +95,14 @@ export default {
// edge case where new tanks don't have averages // edge case where new tanks don't have averages
if (tankAverages[tankId]) { if (tankAverages[tankId]) {
const tankWN8 = getWN8(tankAverages[tankId].all, stats); const tankWN8 = getWN8(tankAverages[tankId].all, stats);
hasWN8AccumulatedAtAll = true;
return accumulator + tankWN8 * stats.battles; return accumulator + tankWN8 * stats.battles;
} else return accumulator; } else return accumulator;
}, 0) / totalBattles, }, 0) / totalBattles,
}; };
if (!hasWN8AccumulatedAtAll) supplementaryStats.WN8 = undefined;
stats = sumStats(entries.map(([, stats]) => stats)); stats = sumStats(entries.map(([, stats]) => stats));
} }
+6 -2
View File
@@ -17,10 +17,14 @@ export default function GenericAllStats({
['Winrate', `${(100 * (stats.wins / stats.battles)).toFixed(2)}%`], ['Winrate', `${(100 * (stats.wins / stats.battles)).toFixed(2)}%`],
[ [
'WN8', 'WN8',
supplementaryStats?.WN8.toFixed(0),
supplementaryStats supplementaryStats
? getWN8Percentile(supplementaryStats.WN8) ? supplementaryStats.WN8 === undefined
? '--'
: supplementaryStats.WN8.toFixed(0)
: undefined, : undefined,
supplementaryStats?.WN8 === undefined
? undefined
: getWN8Percentile(supplementaryStats.WN8),
], ],
[ [
'Survival', 'Survival',
+2 -1
View File
@@ -19,7 +19,8 @@ export interface AllStats {
} }
export interface SupplementaryStats { export interface SupplementaryStats {
WN8: number; // if undefined, WN8 is not available for tanks without averages
WN8?: number;
tier: number; tier: number;
} }