Skip to content

feat(profile): derive the profile P&L from the real round ledger#53

Merged
netqo merged 1 commit into
devfrom
feat/profile-pnl-stats
Jun 23, 2026
Merged

feat(profile): derive the profile P&L from the real round ledger#53
netqo merged 1 commit into
devfrom
feat/profile-pnl-stats

Conversation

@netqo

@netqo netqo commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

Phase 2 (final) of the stats layer: the profile's P&L and game-activity blocks now read the persisted game_round ledger instead of placeholder numbers. With history and round detail already wired, this closes the stats layer - the three round-consuming screens all show real data.

Rationale

ProfileViewModel combines AuthRepository.currentUser (the real identity, already wired) with GameRepository.rounds (the real rounds). The identity, Error and sign-out behaviour are unchanged; only the P&L and game-activity blocks move from placeholders to computed values:

  • All-time P&L: net (= won - wagered), bets, win rate, won and wagered, plus the won/wagered proportion for the split bar.
  • Per-game activity: rounds grouped by game (bets, wagered, net per game), ordered by volume, each with its by-volume bar.
  • Empty ledger: zeros plus a "No game activity yet" empty state in the activity card, so a fresh account shows nothing invented.

Kept scoped to the ViewModel + the activity empty state; the screen composables and the data shapes (ProfilePnl, GameActivityRow) are unchanged.

Verification

  • ./gradlew testDebugUnitTest detekt ktlintCheck assembleDebug compileDebugAndroidTestKotlin green locally (JDK 17).
  • ProfileViewModelTest extended: identity/error/sign-out cases preserved, plus new cases asserting the P&L and game-activity derivation from rounds.
  • Installed the debug APK on a physical device: played coinflip rounds, confirmed the P&L summary and the Coinflip activity row reflect the real wagered/net, and that a fresh account shows zeros + "No game activity yet".

Test plan

  • P&L summary (net, bets, win rate, won/wagered) reflects the played rounds.
  • Game Activity lists one row per game played with correct bets/wagered/net.
  • An empty ledger shows zeros and "No game activity yet".
  • Identity, settings sheet and Sign Out still work.

Related issues

Refs the stats-layer work for the final entrega (phase 2 of 2; closes the stats layer).

Checklist

  • Commit messages follow Conventional Commits (see CONTRIBUTING.md).
  • Branch name follows the naming convention (feat/, fix/, chore/, etc.).
  • The change is scoped: no unrelated edits sneaked into this PR.
  • If user-visible behavior changed, CHANGELOG.md has been updated under [Unreleased].
  • If a new dependency was added, it is justified in the PR description. (No new dependencies.)

ProfileViewModel now combines the signed-in identity with
GameRepository.rounds, replacing the placeholder P&L and game-activity
blocks with values computed from the persisted game_round ledger.

The all-time summary (net, bets, win rate, won/wagered) and the per-game
activity breakdown (bets, wagered and net per game, ordered by volume)
come from the real rounds; with no rounds the screen shows zeros and a
"No game activity yet" empty state.

This closes the stats layer: history, round detail and the profile now
all read real rounds. Covered by the extended ProfileViewModelTest.
@netqo netqo merged commit 96a2684 into dev Jun 23, 2026
3 checks passed
@netqo netqo deleted the feat/profile-pnl-stats branch June 23, 2026 20:39
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.

1 participant