first reading the start of a map with a 3 minute delay to overcome the transition period from the previous map

This commit is contained in:
jenz
2026-10-04 20:50:33 +02:00
parent 7a6051987e
commit d64f8c3f29
5 changed files with 32 additions and 5 deletions
@@ -1,5 +1,6 @@
import { query } from '@/lib/db';
import { parseDbDate } from '@/lib/dates';
import { START_BASELINE_MS } from '@/lib/populationBaseline';
// --- Why this exists ---------------------------------------------------
//
@@ -120,7 +121,11 @@ async function computeMapImpactStats(): Promise<MapImpactSummary[]> {
const durationMs = nextStartMs - startMs;
if (durationMs < MIN_REAL_PERIOD_MS) continue; // tickrate-restart artifact, not a real occurrence
const startPlayers = populationAt(startMs);
// Read the starting population START_BASELINE_MS into the map rather than
// at the exact change instant, so players still leaving the previous map
// aren't counted against this one. Clamped to the occurrence's end (it is
// always >= 2 min long here, but may be shorter than the baseline).
const startPlayers = populationAt(Math.min(startMs + START_BASELINE_MS, nextStartMs));
const endPlayers = populationAt(nextStartMs);
const netChange = endPlayers - startPlayers;
const retentionPct = startPlayers > 0 ? (endPlayers / startPlayers) * 100 : null;