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:
@@ -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;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// How long after a map starts we wait before reading its "starting"
|
||||
// population. At the exact instant of a map change the player count is still
|
||||
// the previous map's (people leaving or reconnecting), so reading it at t=0
|
||||
// would blame the new map for attrition that happened before/around the
|
||||
// change. Shared by the leaderboard, the population chart SQL and the
|
||||
// per-session timeline so all three agree. Safe to import from client code.
|
||||
export const START_BASELINE_MIN = 3;
|
||||
export const START_BASELINE_MS = START_BASELINE_MIN * 60_000;
|
||||
@@ -1,4 +1,5 @@
|
||||
import { query } from '@/lib/db';
|
||||
import { START_BASELINE_MIN } from '@/lib/populationBaseline';
|
||||
|
||||
// map_end_dt was dropped from the schema — it was redundant with (and
|
||||
// occasionally got out of sync with) the next row's map_start_dt, since a
|
||||
@@ -123,8 +124,8 @@ export async function getMapPopulationSeries(limit = 40, before?: string): Promi
|
||||
AND (s.session_end_dt IS NULL OR s.session_end_dt > m.map_start_dt)
|
||||
) AS total_players,
|
||||
(SELECT COUNT(DISTINCT s.steamid) FROM playtime_display_sessions s
|
||||
WHERE s.session_start_dt <= m.map_start_dt
|
||||
AND (s.session_end_dt IS NULL OR s.session_end_dt > m.map_start_dt)
|
||||
WHERE s.session_start_dt <= LEAST(m.map_start_dt + INTERVAL ${START_BASELINE_MIN} MINUTE, COALESCE(${NEXT_MAP_START('m')}, NOW()))
|
||||
AND (s.session_end_dt IS NULL OR s.session_end_dt > LEAST(m.map_start_dt + INTERVAL ${START_BASELINE_MIN} MINUTE, COALESCE(${NEXT_MAP_START('m')}, NOW())))
|
||||
) AS start_players,
|
||||
(SELECT COUNT(DISTINCT s.steamid) FROM playtime_display_sessions s
|
||||
WHERE s.session_start_dt <= COALESCE(${NEXT_MAP_START('m')}, NOW())
|
||||
|
||||
Reference in New Issue
Block a user