fix: swapped min and max for start and end

This commit is contained in:
TresAbhi committed 2023-08-09 17:51:19 +00:00
1 parent 8253c27333
commit e806f0ede2
2 files changed
+11 -28

No files matched your search

+10 -10
View File
@@ -17,7 +17,7 @@ export interface ResolvedPeriod {
}
export default function resolvePeriodFromCommand(
server: Region,
region: Region,
interaction: ChatInputCommandInteraction<CacheType>,
) {
let statsName: string;
@@ -28,19 +28,19 @@ export default function resolvePeriodFromCommand(
const periodOption = interaction.options.getString('period') as PeriodSize;
if (periodSubcommand === 'custom') {
const startRaw = interaction.options.getInteger('start')!;
const endRaw = interaction.options.getInteger('end')!;
const startMin = Math.min(startRaw, endRaw);
const endMax = Math.max(startRaw, endRaw);
const startRaw = interaction.options.getInteger('start', true);
const endRaw = interaction.options.getInteger('end', true);
const startDaysAgoMax = Math.min(startRaw, endRaw);
const endDaysAgoMin = Math.max(startRaw, endRaw);
statsName = `${startMin} to ${endMax} days' statistics`;
evolutionName = `${startMin} to ${endMax} days' evolution`;
start = getTimeDaysAgo(server, startMin);
end = getTimeDaysAgo(server, endMax);
statsName = `${startDaysAgoMax} to ${endDaysAgoMin} days' statistics`;
evolutionName = `${startDaysAgoMax} to ${endDaysAgoMin} days' evolution`;
start = getTimeDaysAgo(region, endDaysAgoMin);
end = getTimeDaysAgo(region, startDaysAgoMax);
} else {
statsName = `${getPeriodOptionName(periodOption)} Statistics`;
evolutionName = `${getPeriodOptionName(periodOption)} Evolution`;
start = getPeriodStart(server, periodOption);
start = getPeriodStart(region, periodOption);
end = getPeriodNow();
}
+1 -18
View File
@@ -2,14 +2,13 @@ import AllStatsOverview from '../components/AllStatsOverview';
import NoData, { NoDataType } from '../components/NoData';
import PoweredBy, { PoweredByType } from '../components/PoweredBy';
import { TreeTypeString } from '../components/Tanks';
import { TierWeightsRecord } from '../components/TierWeights';
import TitleBar from '../components/TitleBar';
import Wrapper from '../components/Wrapper';
import calculateWN8 from '../core/blitz/calculateWN8';
import getWargamingResponse from '../core/blitz/getWargamingResponse';
import resolveTankName from '../core/blitz/resolveTankName';
import sumStats from '../core/blitz/sumStats';
import { Tier, tankopedia } from '../core/blitz/tankopedia';
import { tankopedia } from '../core/blitz/tankopedia';
import getDiffedTankStats from '../core/blitzstars/getDiffedTankStats';
import { tankAverages } from '../core/blitzstars/tankAverages';
import { ResolvedPeriod } from '../core/discord/resolvePeriodFromCommand';
@@ -67,7 +66,6 @@ export default async function stats<Type extends StatType>(
const awaitedTankopedia = await tankopedia;
let stats: AllStats | undefined;
let supplementaryStats: SupplementaryStats;
let tierWeights: TierWeightsRecord;
if (type === 'player' || type === 'multi-tank') {
const typedFilters = filters as Partial<MultiTankFilters> | null;
@@ -124,21 +122,6 @@ export default async function stats<Type extends StatType>(
0,
) / battlesOfTanksWithTankopediaEntry,
};
tierWeights = filteredOrder.reduce<TierWeightsRecord>((accumulator, id) => {
const tankopediaEntry = awaitedTankopedia[id];
if (!tankopediaEntry) return accumulator;
const tier = tankopediaEntry.tier as Tier;
if (accumulator[tier]) {
accumulator[tier]! += diffed[id].battles;
} else {
accumulator[tier] = diffed[id].battles;
}
return accumulator;
}, {});
} else {
stats = diffed[(filters as number)!];