fix: stats now handles unowned tanks

This commit is contained in:
TresAbhi committed 2023-07-05 01:28:59 +00:00
1 parent 433ffba1e3
commit 95b105cb65
3 files changed
+8 -6

No files matched your search

+1 -1
View File
@@ -20,7 +20,7 @@ import { AccountInfo } from '../types/accountInfo.js';
export const evolutionCommand: CommandRegistry = { export const evolutionCommand: CommandRegistry = {
inProduction: true, inProduction: true,
inDevelopment: false, inDevelopment: true,
inPublic: true, inPublic: true,
command: addStatTypeSubCommandGroups( command: addStatTypeSubCommandGroups(
+1 -1
View File
@@ -20,7 +20,7 @@ import { AccountInfo } from '../types/accountInfo.js';
export const statsCommand: CommandRegistry = { export const statsCommand: CommandRegistry = {
inProduction: true, inProduction: true,
inDevelopment: false, inDevelopment: true,
inPublic: true, inPublic: true,
command: addStatTypeSubCommandGroups( command: addStatTypeSubCommandGroups(
+6 -4
View File
@@ -52,7 +52,7 @@ export default async function stats<Type extends StatType>(
} }
const tankStats = await getTankStatsDiffed(server, id, start, end); const tankStats = await getTankStatsDiffed(server, id, start, end);
let stats: AllStats; let stats: AllStats | undefined;
let supplementaryStats: SupplementaryStats; let supplementaryStats: SupplementaryStats;
let tierWeights: TierWeightsRecord; let tierWeights: TierWeightsRecord;
@@ -117,7 +117,9 @@ export default async function stats<Type extends StatType>(
stats = tankStats[tankId!]; stats = tankStats[tankId!];
supplementaryStats = { supplementaryStats = {
WN8: calculateWN8(tankAverages[tankId!].all, tankStats[tankId!]), WN8: stats
? calculateWN8(tankAverages[tankId!].all, tankStats[tankId!])
: undefined,
tier: tankopedia[tankId!].tier, tier: tankopedia[tankId!].tier,
}; };
} }
@@ -154,8 +156,8 @@ export default async function stats<Type extends StatType>(
}`} }`}
/> />
{stats.battles === 0 && <NoData type={NoDataType.BattlesInPeriod} />} {!stats?.battles && <NoData type={NoDataType.BattlesInPeriod} />}
{stats.battles > 0 && overview} {stats?.battles > 0 && overview}
<PoweredBy type={PoweredByType.BlitzStars} footer={footer} /> <PoweredBy type={PoweredByType.BlitzStars} footer={footer} />
</Wrapper> </Wrapper>