Skip to content

feat: copy each deck's win summary onto its deck doc - #587

Open
TytaniumDev wants to merge 1 commit into
mainfrom
claude/project-thread-hgnb15
Open

TytaniumDev wants to merge 1 commit into
mainfrom
claude/project-thread-hgnb15

Conversation

@TytaniumDev

Copy link
Copy Markdown
Owner

Requested by Tyler · project thread

Summary

Tyler chose "flag plus a rating summary" for deck docs, so a future page can list decks with their stats without reading every stats/rating doc.

  • Aggregation: RatingStore.applyJob (Firestore) writes summary: { gamesPlayed, wins, winRate } onto each rated deck's decks/{id} doc in the same transaction that updates its rating.
    • It uses update, not set, so a deck deleted since its job ran is not recreated.
    • winRate is stored rather than derived so decks can be sorted by it.
  • Reads: GET /api/decks and getDeckById return summary (null until the deck has rated games). Local mode joins the SQLite ratings rows in at read time (listDeckSummaries).
  • Data wipe: a new deckSummaries leftover kind clears the summaries on precon docs after ratings are wiped. In SQLite it's a no-op.
  • Docs: DATA_FLOW.md, docs/ARCHITECTURE.md and CLAUDE.md are updated.

Test plan

  • New test/deck-summary.test.ts (added to test:unit) passes on both SQLite and the Firestore emulator: an unrated deck has no summary, a rated deck lists its games, wins and win rate, and wiping ratings clears the summaries.
  • rating-store, data-wipe and deck-selection-store tests pass on the emulator.
  • npm run lint --prefix api, npm run test:unit --prefix api, frontend tsc -b.

Generated by Claude Code

Aggregation's ratings transaction now writes summary { gamesPlayed, wins,
winRate } onto each rated deck's doc, so GET /api/decks lists win stats
without reading stats docs. Local mode joins the ratings rows in at read
time. A data wipe clears the summaries with the ratings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FUGyg98DxHVdFazZLDFw7b
@TytaniumDev TytaniumDev self-assigned this Oct 30, 2026
@TytaniumDev
TytaniumDev enabled auto-merge (squash) October 30, 2026 06:51

This branch has not been deployed

No deployments
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