fix: variant filter commented out on cards list endpoint (#197) #203

Merged
cal merged 2 commits from issue/197-bug-variant-filter-commented-out-on-cards-list-end into main 2026-04-08 01:45:08 +00:00
Collaborator

Summary

  • Uncomments the ?variant= query filter on GET /api/v2/cards so callers can pass variant=0 for base cards only or variant=N for a specific refractor variant
  • Adds variant column to the CSV export header and row data

Changes

app/routers_v2/cards.py:

  • Lines 82–83: uncommented if variant is not None: all_cards = all_cards.where(Card.variant == variant)
  • Lines 117–118: added "variant" to CSV header list
  • Line 128: replaced line.value # line.variant with line.value, line.variant

Test plan

  • GET /api/v2/cards?team_id=X returns both base and variant cards (no filter)
  • GET /api/v2/cards?team_id=X&variant=0 returns only base cards
  • GET /api/v2/cards?team_id=X&variant=1 returns only variant=1 cards
  • GET /api/v2/cards?team_id=X&csv=true includes variant column in output

Closes #197

🤖 Generated with Claude Code

## Summary - Uncomments the `?variant=` query filter on `GET /api/v2/cards` so callers can pass `variant=0` for base cards only or `variant=N` for a specific refractor variant - Adds `variant` column to the CSV export header and row data ## Changes `app/routers_v2/cards.py`: - Lines 82–83: uncommented `if variant is not None: all_cards = all_cards.where(Card.variant == variant)` - Lines 117–118: added `"variant"` to CSV header list - Line 128: replaced `line.value # line.variant` with `line.value, line.variant` ## Test plan - [ ] `GET /api/v2/cards?team_id=X` returns both base and variant cards (no filter) - [ ] `GET /api/v2/cards?team_id=X&variant=0` returns only base cards - [ ] `GET /api/v2/cards?team_id=X&variant=1` returns only variant=1 cards - [ ] `GET /api/v2/cards?team_id=X&csv=true` includes `variant` column in output Closes #197 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Claude added 1 commit 2026-04-08 00:32:02 +00:00
Restores the commented-out `?variant=` query filter on GET /api/v2/cards
so callers can pass variant=0 for base cards or variant=N for a specific
refractor variant. Adds variant column to CSV output header and rows.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude added the
ai-reviewing
label 2026-04-08 00:45:54 +00:00
Claude reviewed 2026-04-08 00:46:52 +00:00
Claude left a comment
Author
Collaborator

AI Code Review

Files Reviewed

  • app/routers_v2/cards.py (modified)

Findings

Correctness

No issues found.

  • Variant filter (lines 82–83): variant: Optional[int] = None was already declared in the endpoint signature (line 44); Card.variant exists (confirmed via CardPydantic at line 29 and PATCH /{card_id} at line 351). Uncommenting the filter is correct.
  • CSV header (lines 117–118): Header now has 8 columns: id, player, cardset, rarity, team, pack, value, variant. Correct.
  • CSV row (line 128): Row now has 8 values matching the 8 headers. Column count is consistent. Correct.

Security

No issues found. The variant filter uses Peewee's ORM query builder, which parameterizes inputs — no SQL injection risk.

Style & Conventions

No issues found. Change follows existing filter pattern used for value, team_id, player_id, etc.

Suggestions

  • PATCH /{card_id} at line 351 also declares variant as a parameter but still has the assignment commented out (lines 379–380: # if variant is not None: # this_card.variant = variant). This is pre-existing and out of scope here, but worth a follow-up issue if PATCH variant updates are needed.
  • No tests added. Consistent with the codebase pattern of following up with a separate test PR, but a simple test for variant=0 and variant=N filtering would be valuable.

Verdict: COMMENT

No blocking issues. Changes are minimal, correct, and implement exactly what the PR claims. mergeable: true. Ready to merge.

Self-review restriction: posting as COMMENT per project convention.


Automated review by Claude PR Reviewer

## AI Code Review ### Files Reviewed - `app/routers_v2/cards.py` (modified) ### Findings #### Correctness No issues found. - **Variant filter** (lines 82–83): `variant: Optional[int] = None` was already declared in the endpoint signature (line 44); `Card.variant` exists (confirmed via `CardPydantic` at line 29 and `PATCH /{card_id}` at line 351). Uncommenting the filter is correct. - **CSV header** (lines 117–118): Header now has 8 columns: `id, player, cardset, rarity, team, pack, value, variant`. Correct. - **CSV row** (line 128): Row now has 8 values matching the 8 headers. Column count is consistent. Correct. #### Security No issues found. The variant filter uses Peewee's ORM query builder, which parameterizes inputs — no SQL injection risk. #### Style & Conventions No issues found. Change follows existing filter pattern used for `value`, `team_id`, `player_id`, etc. #### Suggestions - `PATCH /{card_id}` at line 351 also declares `variant` as a parameter but still has the assignment commented out (lines 379–380: `# if variant is not None: # this_card.variant = variant`). This is pre-existing and out of scope here, but worth a follow-up issue if PATCH variant updates are needed. - No tests added. Consistent with the codebase pattern of following up with a separate test PR, but a simple test for `variant=0` and `variant=N` filtering would be valuable. ### Verdict: COMMENT No blocking issues. Changes are minimal, correct, and implement exactly what the PR claims. `mergeable: true`. Ready to merge. _Self-review restriction: posting as COMMENT per project convention._ --- *Automated review by Claude PR Reviewer*
Claude added the
ai-reviewed
label 2026-04-08 00:47:08 +00:00
cal approved these changes 2026-04-08 01:44:59 +00:00
cal left a comment
Owner

Approved via pd-pr

Approved via pd-pr
cal added 1 commit 2026-04-08 01:45:05 +00:00
cal merged commit 3852fe1408 into main 2026-04-08 01:45:08 +00:00
cal deleted branch issue/197-bug-variant-filter-commented-out-on-cards-list-end 2026-04-08 01:45:08 +00:00
Sign in to join this conversation.
No description provided.