Add expanded card stats — /api/runs/card-stats + Stats tab block#264
Open
ptrlrd wants to merge 1 commit into
Open
Add expanded card stats — /api/runs/card-stats + Stats tab block#264ptrlrd wants to merge 1 commit into
ptrlrd wants to merge 1 commit into
Conversation
…block Roadmap #2 (after Codex Score). Adds richer per-card community-meta stats to the card detail page Stats tab beyond the bulk Codex Score feed. New endpoint GET /api/runs/card-stats/{card_id} backed by get_card_stats() in services/runs_db.py. Aggregates from existing run_cards + run_card_choices tables — no schema migration. Returned fields: pick_rate / skip_rate from run_card_choices win_rate_when_in_deck runs containing card / total of those avg_copies_winning / avg_copies_all deck composition signal upgrade_rate % of times upgraded when present avg_ascension_picked skews up for late-game darlings top_synergies (top 5) self-join on run_cards in wins Computed on-demand. Each detail-page hit is one bounded SELECT + one synergy self-join (rows for one card_id ~ low thousands, fans out to ~30 deck slots each). Well under the score-walker pre-warm budget. Rate-limited at 120/min to match the existing /stats endpoints. EntityRunStats now fetches /api/runs/card-stats/{id} additionally when entityType === "cards" and renders a six-tile grid + top-5 synergy list below the prose summary. Stat tile component lives in the same file since it's not used elsewhere. prettyId helper title-cases UPPER_SNAKE ids cheaply (no name-lookup round-trip) — fine since synergy cards are clickable to their detail pages where the canonical name lives. contributing/API_REFERENCE.md gets a new row documenting the endpoint and the field set.
624c9e1 to
2507327
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-created after the 2026-05-14 12:42 UTC repo rollback closed the original #249.
Roadmap #2 of the stats expansion. New GET /api/runs/card-stats/{card_id} returning pick_rate, skip_rate, win_rate_when_in_deck, avg_copies_winning/_all, upgrade_rate, avg_ascension_picked, top_synergies (top 5 cards co-present in winning decks). Frontend EntityRunStats renders a 6-tile grid + synergy list for entityType==='cards'. Reuses run_cards + run_card_choices, no schema change.