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,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())