fix: implement paperdex dupe-detection logic (#23) #70
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
ai-working
bug
enhancement
feature
in-queue
performance
security
tech-debt
todo
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-discord#70
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/paper-dynasty-discord#23"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements the dupe-detection logic that was stubbed out as a TODO in
get_card_embeds().cardsAPI endpoint filtered byplayer_id+team_idto count how many copies of the card the viewing team owns# Dupesembed field (e.g. "0 dupes", "1 dupe", "3 dupes") for non-Paper-Dynasty teamshelpers/main.pyandhelpers.pyFiles Changed
helpers/main.py— removed TODO comment block, implemented dupe detectionhelpers.py— same change (legacy file, kept in sync)Notes
The
paperdexdata already fetched viadb_get("paperdex", flat=True)tracks "has ever collected" (one entry per player-team pair), so it cannot yield dupe counts on its own. A separatecardsAPI call per card embed is required. The original commented-out approach was correct.The
count - 1logic from the original stub was replaced withdupe_count = 0 if not team_dex["count"] else team_dex["count"] - 1to correctly handle the edge case wherecountis 0 (team has no cards of this player — shouldn't appear in practice but avoids -1 dupes display).Other observations
helpers.py(top-level) appears to be a legacy duplicate ofhelpers/package — it still exists onmainbranch. PRs #62 and #65 onnext-releaseaddress this.paperdex_team_embedin each file (string split across line change) — functional code is unchanged.AI Code Review
Files Reviewed
helpers/main.py(modified)helpers.py(modified — legacy duplicate, kept in sync)Findings
Correctness
dupe_count = 0 if not team_dex["count"] else team_dex["count"] - 1is correct. Handles count=0 (→ 0 dupes, avoids -1), count=1 (→ 0 dupes, single copy), count=N (→ N-1 dupes). The PR's fix over the original stub'scount = 1 if not team_dex['count'] else team_dex['count']approach is cleaner.if card["team"]["lname"] != "Paper Dynasty":matches the identical guard already used for "Collected By" display above (line 157), ensuring consistent behavior.db_get("cards", params=[("player_id", ...), ("team_id", ...)])mirrors the exact same pattern used at line 153 fordb_get("paperdex", ...)— consistent with the existing code.team_dex["count"]could raise ifdb_getreturnsNone. However, the surrounding code (all_dex["count"]at line 156) has the same assumption, so this is consistent with project patterns — not a blocker.Security
player_idandteam_idare sourced from API response data and passed as HTTP query params, not raw SQL. No injection risk.Style & Conventions
dupe/dupes) is consistent with the other embed fields in this function.paperdex_team_embed— functionally unchanged.Suggestions
Verdict: APPROVED
Clean implementation of the stubbed TODO. Logic is correct, edge cases handled, follows existing project patterns. The
helpers.pysync is noted as intentional (legacy file, addressed by PRs #62/#65 onnext-release).Automated review by Claude PR Reviewer
37041b028eto174c485c85Closing — will re-implement fresh against
main. Original PR had unrebaseable conflicts from the scouting refactor.Pull request closed