Exclude same-round departures from games played

This commit is contained in:
2026-10-08 16:12:13 -04:00
parent 63e084e38f
commit a18635fb78
8 changed files with 73 additions and 7 deletions
+3 -1
View File
@@ -1,6 +1,7 @@
import { db } from '../db/index.js';
import { MIN_RECORDED_ROUND } from '../../match-history.js';
import { getPersonalBestRecords } from './leaderboard-records.js';
import { countsAsGamePlayed } from './leaderboard-participation.js';
import { EFFICIENCY_MIN_GAMES, EFFICIENCY_MIN_KILLS, EFFICIENCY_MIN_DOWNS,
isEfficiencyMetric } from '../../leaderboard-efficiency.js';
import { leaderboardMetrics, type LeaderboardEntry, type LeaderboardMap, type LeaderboardMetric,
@@ -74,6 +75,7 @@ function readLeaderboard(options: LeaderboardOptions, exactGuid?: string): Leade
const aggregated = `WITH observations AS ${observationStorage} (
SELECT mp.match_id, mp.guid, mp.highest_round, mp.kills, mp.rounds_survived,
mp.headshots, mp.revives, mp.downs, mp.completed, mp.best_score, mp.last_seen_at,
${countsAsGamePlayed} AS counts_as_game,
m.started_at AS matchStartedAt, m.last_received_at AS matchUpdatedAt
FROM leaderboard_match_players mp JOIN leaderboard_matches m ON m.id = mp.match_id
WHERE ${conditions.join(' AND ')}
@@ -81,7 +83,7 @@ function readLeaderboard(options: LeaderboardOptions, exactGuid?: string): Leade
SELECT guid, MAX(highest_round) AS highestRound,
SUM(kills) AS kills, SUM(rounds_survived) AS roundsSurvived,
SUM(headshots) AS headshots, SUM(revives) AS revives, SUM(downs) AS downs,
COUNT(*) AS gamesPlayed, SUM(completed) AS gamesCompleted,
SUM(counts_as_game) AS gamesPlayed, SUM(completed) AS gamesCompleted,
MAX(kills) AS bestKills, MAX(best_score) AS bestScore, MAX(last_seen_at) AS lastSeen
FROM observations GROUP BY guid
), measures AS (