Skip to content

Your play time card counts every PC of the account - #328

Merged
elripalda merged 7 commits into
elripalda:mainfrom
Xarishark:feat/playtime-account-wide-929d66
Nov 20, 2026
Merged

elripalda merged 7 commits into
elripalda:mainfrom
Xarishark:feat/playtime-account-wide-929d66

Conversation

@Xarishark

@Xarishark Xarishark commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

What this changes

A game page's Your play time card (this week, this month, sessions, longest, the last two weeks) now counts every PC of the account when signed in, not just this one. Played and Last played were already account wide (#251 and the playtime sync); the card was still drawn from this PC's sessions only, because the website kept a total per game and no sessions.

Launcher

Each PC sends, with each game's total, what the card needs and no more (PlayEntry in library.rs):

  • count: how many sessions it kept of the game (10 seconds or more each, its newest 500).
  • longest: the longest of them.
  • recent: its sessions of the last 31 days, as [start, secs], for this week, this month and the bars.

Older sessions aren't sent: the card shows nothing of them but count and longest, so a full send stays small.

playStats (games.js) builds the card: the account's recent sessions joined with this PC's (a session is the same one when start and length match, so this PC's own aren't counted twice), and the larger of the account's and this PC's count and longest, so a session the website hasn't heard about yet still shows. Anything malformed from the website is left out. Signed out, or a website without these fields: the card is this PC's own, as before.

Website (needed before other PCs show up)

docs/LAUNCHER-API.md, Playtime: per PC, count and longest keep the larger of stored and sent (like secs); recent sessions are added to what it had (deduped by both numbers), with anything older than 31 days dropped. GET ?a=play gives each game count summed over the PCs, longest the largest, and every PC's recent together, oldest first. Titles don't carry them. tools/fake-play-site.cjs does this, to try it locally with RL_API.

Signing in again doesn't count a PC twice

The website told PCs apart by their sign-in token, so a PC that signed out and back in became a new PC sending its whole running total again: Played (and now Sessions) counted twice. Each ?a=play send now carries pc, a random play ID kept in play.id in the data folder (cloud::play_id), the same however often the PC signs in. The website keeps play rows by account and play ID; a sign-in's earlier rows move to its play ID when it first sends one, merged by the larger of each number.

It's its own ID, used for play time only: not the usage ID (install.id), which only goes when the player shares usage and Settings can reset. Sign-in, the PC list and cloud saves are unchanged. Rows from sign-ins already gone before this stay as they are.

Testing

  • node --test tests/*.test.cjs: 340 passed (5 new: every PC's recent sessions once, count and longest from the account, a session not on the account yet, signed out, bad data left out).
  • cargo test: 693 passed (4 new: entries carry recent sessions; older sessions count but aren't sent; the play ID stays the same; it isn't the usage ID).
  • The fake site with two signed-in PCs: count summed and not doubled by a resend, longest kept from a 40-day-old session, sessions older than 31 days and a bad one left out of recent.
  • The fake site, one PC: an older launcher's row moved to the play ID, and signing in again then sending kept one row at 630 s, not 1230.
  • Live, against recomplauncher.com with the debug build on two test PCs (separate data folders): PC A (70 min over 3 sessions, one 60 days old) then PC B (15 min). PC B's game page showed 1 hour 25 min played; its card This week 45 min, This month 45 min, Sessions 4, Longest 40 min, bars from both PCs. PC A signed out, signed in again and resent everything: still 1 hour 25 min and 4 sessions, same play ID.

@Xarishark
Xarishark marked this pull request as ready for review November 20, 2026 00:49
@elripalda
elripalda merged commit 5715143 into elripalda:main Nov 20, 2026
6 checks passed
@Xarishark
Xarishark deleted the feat/playtime-account-wide-929d66 branch November 23, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants