Public Access
feat(library): playtime history per day and a nightly sync
Each sync records the growth of playtime per game and day (Europe/Berlin). The first successful sync of a Steam account is only the baseline, tracked in user_steam_sync.history_steam_id, so a new or failed account never turns its whole playtime into one day. A nightly sync at 23:55 runs the recently used accounts one after the other. GET /api/library/activity returns minutes per day and the games of Steam's last two weeks.
This commit is contained in:
1 parent
afa2a7ea75
commit
ba1f1e6fe1
24 files changed
+607
-12
No files matched your search
@@ -0,0 +1,21 @@
|
||||
-- Minutes played per user, game and day (Europe/Berlin), as the growth of playtime_forever between two syncs.
|
||||
-- The first sync of a Steam account is only the baseline and writes no rows.
|
||||
CREATE TABLE user_game_playtime_day (
|
||||
user_id BIGINT NOT NULL,
|
||||
day DATE NOT NULL,
|
||||
appid BIGINT NOT NULL,
|
||||
minutes INTEGER NOT NULL CHECK (minutes > 0),
|
||||
PRIMARY KEY (user_id, day, appid)
|
||||
);
|
||||
|
||||
-- The Steam account whose playtime is the baseline for the history: set after a successful sync only.
|
||||
-- Growth is recorded only while it equals steam_id, so a failed first sync of a new account cannot turn
|
||||
-- that account's whole playtime into one day.
|
||||
ALTER TABLE user_steam_sync ADD COLUMN history_steam_id VARCHAR(32);
|
||||
|
||||
-- Last request of the user. The nightly sync skips accounts nobody used for a while, e.g. after the user
|
||||
-- removed the Steam ID (Core does not learn about that).
|
||||
ALTER TABLE user_steam_sync ADD COLUMN user_seen_at TIMESTAMPTZ;
|
||||
|
||||
-- Steam's own "last two weeks" playtime, updated on every sync.
|
||||
ALTER TABLE user_game ADD COLUMN playtime_2weeks INTEGER NOT NULL DEFAULT 0;
|
||||
Reference in new issue
Block a user