fix(sync): keep old playtime off the day a game shows up

A game the sync saw for the first time put its whole playtime on that
day (40 h "longest gaming day" after skip_unvetted_apps=0). Growth now
counts at most Steam's last two weeks, and one game gets at most 24 h
per day. V18 drops the bad rows and caps old ones.
This commit is contained in:
lobo committed 2026-09-27 10:00:53 +02:00
1 parent 0fa2a37f47
commit 01552ecd89
6 files changed
+88 -9

No files matched your search

@@ -0,0 +1,17 @@
-- Until now, a game a sync saw for the first time put its whole playtime_forever on that day, e.g. 40 hours on one
-- day for an app that skip_unvetted_apps=0 brought in. Drop these rows: the minutes such a game really got on that
-- day cannot be told apart from its older playtime.
-- The games of the first sync are the baseline: they share one first_seen_at, and their rows on that day are real.
WITH baseline AS (
SELECT user_id, mode() WITHIN GROUP (ORDER BY first_seen_at) AS first_seen_at
FROM user_game
GROUP BY user_id
)
DELETE FROM user_game_playtime_day p
USING user_game ug, baseline b
WHERE ug.user_id = p.user_id AND ug.appid = p.appid AND b.user_id = ug.user_id
AND (ug.first_seen_at AT TIME ZONE 'Europe/Berlin')::date = p.day
AND ug.first_seen_at <> b.first_seen_at;
-- A gap between syncs put several days on one day; one game now gets at most one day per day.
UPDATE user_game_playtime_day SET minutes = 1440 WHERE minutes > 1440;