Consider tier for recent results

This commit is contained in:
Kalle
2026-03-30 18:06:18 +03:00
parent c2984696d6
commit 8b1a949ebe

View File

@@ -189,10 +189,10 @@ function deleteExtraResults(tournaments: ShowcaseCalendarEvent[]) {
const rankedResults = tournaments
.filter((tournament) => tournament.firstPlacer && tournament.isRanked)
.sort((a, b) => b.teamsCount - a.teamsCount);
.sort((a, b) => showcaseScore(b) - showcaseScore(a));
const nonRankedResults = tournaments
.filter((tournament) => tournament.firstPlacer && !tournament.isRanked)
.sort((a, b) => b.teamsCount - a.teamsCount);
.sort((a, b) => showcaseScore(b) - showcaseScore(a));
const rankedResultsToKeep = rankedResults.slice(0, 4);
// min 2, max 6 non ranked results
@@ -383,3 +383,13 @@ function databaseTimestampSixHoursAgo() {
return dateToDatabaseTimestamp(now);
}
const TIER_BONUS_PER_STEP = 5;
function showcaseScore(tournament: ShowcaseCalendarEvent): number {
const tierBonus =
typeof tournament.tier === "number"
? (10 - tournament.tier) * TIER_BONUS_PER_STEP
: 0;
return tournament.teamsCount + tierBonus;
}