-
Notifications
You must be signed in to change notification settings - Fork 714
lobby fill time added to stats #2382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds a lobby creation timestamp to GameStartInfo and ServerStartGameMessage, threads that timestamp into record creation and archiving, computes lobby fill time in createPartialGameRecord, and exposes a new Stats hook lobbyFillTime. Changes
Sequence Diagram(s)sequenceDiagram
participant SP as SinglePlayer (Client)
participant Client as ClientRuntime
participant Server as GameServer
participant Archive as ArchiveService
rect rgb(248,250,255)
Note over SP,Server: Lobby creation time set
SP->>Client: emit JoinLobby (gameStartInfo.config.lobbyCreatedAt = Date.now())
Server->>Server: GameServer.createdAt set => lobbyCreatedAt
end
rect rgb(240,255,245)
Note over Server,Client: Start propagation
Server->>Client: ServerStartGameMessage (includes lobbyCreatedAt)
Client->>Client: LocalServer stores lobbyCreatedAt with game state
end
rect rgb(255,250,240)
Note over Client,Archive: End & archive
Client->>Client: ClientGameRunner.saveGame(..., lobbyCreatedAt)
Client->>Client: createPartialGameRecord(actualLobbyCreatedAt, compute lobbyFillTime)
Client->>Archive: POST Blob(payload) containing record with lobbyCreatedAt & lobbyFillTime
end
rect rgb(245,245,245)
Note over Client: Stats emission
Client->>Client: Stats.lobbyFillTime(lobbyFillTime)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks✅ Passed checks (5 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (2)📚 Learning: 2025-06-09T02:20:43.637ZApplied to files:
📚 Learning: 2025-08-12T00:31:50.144ZApplied to files:
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/core/Util.ts (2)
197-198: Consider clarifying the comment.The comment states the default is "for singleplayer," but the fallback to
startactually applies wheneverlobbyCreatedAtis not provided, regardless of game mode. This could happen in multiplayer too if the data is missing.Consider this wording:
- // lobby creation time (ms). Defaults to start time for singleplayer. + // lobby creation time (ms). Defaults to start time if not provided. lobbyCreatedAt?: number,
206-211: The fill time calculation can be simplified.The nested
Math.minis redundant. The outerMath.max(0, ...)already handles the case whereactualLobbyCreatedAt > start(clock skew) by clamping to zero.Consider simplifying:
// Use start time as lobby creation time for singleplayer const actualLobbyCreatedAt = lobbyCreatedAt ?? start; - const lobbyFillTime = Math.max( - 0, - start - Math.min(actualLobbyCreatedAt, start), - ); + const lobbyFillTime = Math.max(0, start - actualLobbyCreatedAt);Both versions produce the same result, but this is more direct.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/core/Util.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/core/Util.ts (4)
src/core/Schemas.ts (1)
PartialGameRecord(597-597)src/server/GameServer.ts (2)
end(473-523)start(389-427)src/client/LocalServer.ts (1)
start(53-89)src/core/game/StatsImpl.ts (1)
lobbyFillTime(268-268)
🔇 Additional comments (1)
src/core/Util.ts (1)
213-229: LGTM!The new fields are correctly integrated into the returned record. The
lobbyCreatedAtandlobbyFillTimevalues are properly computed and included in theinfoobject.
evanpelle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Finishes & closes openfrontio#1969 and closes openfrontio#1806. - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced regression is found: w.o.n --------- Co-authored-by: Evan <evanpelle@gmail.com> temp disable factory upgrades
## Description: Finishes & closes openfrontio#1969 and closes openfrontio#1806. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: w.o.n --------- Co-authored-by: Evan <evanpelle@gmail.com>
Description:
Finishes & closes #1969 and closes #1806.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
w.o.n