fix: filter variant=0 in scouting queries to exclude boosted stats (#58) #62
No reviewers
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-card-creation#62
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/58-bug-scouting-reports-must-filter-variant-0-to-excl"
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?
Closes #58
Summary
Scouting reports were pulling all
battingcardratings/pitchingcardratingsrows without filtering by variant. Once refractor variant rows (variant > 0) exist in the database, those boosted stats would be included in scouting calculations, making players appear stronger than their base card.Changes
Added
variant=0client-side filter on the API response in all four scouting data-fetch paths:scouting_batters.py—get_scouting_dfs(): filtersvl_valsandvr_valsscouting_pitchers.py—get_scouting_dfs(): filtersvl_valsandvr_valspd_cards/core/scouting.py—get_batting_scouting_dfs(): filtersvl_valsandvr_valspd_cards/core/scouting.py—get_pitching_scouting_dfs(): filtersvl_valsandvr_valsThe filter uses
.get("variant", 0) == 0so it is safe even if the API response does not include avariantfield (defaults to 0 = base card).Test results
No test suite. Changes verified by reading back modified files — the filter list comprehensions are applied before the existing processing loops in all four locations.
Other observations
Pre-existing Pyright type errors exist in
scouting_batters.py,scouting_pitchers.py, andpd_cards/core/scouting.py(unrelated to this fix, not modified).AI Code Review
Files Reviewed
scouting_batters.py(modified)scouting_pitchers.py(modified)pd_cards/core/scouting.py(modified)Findings
Correctness
No issues found. The filter is applied at the right point — before the
for x in vl_vals:andfor x in vr_vals:loops that destructively mutate each item. All eight filter points are covered (vL + vR for batting and pitching, across both the legacy scripts and the CLI-path module). The.get("variant", 0)pattern correctly handles API responses that pre-date the variant field.Security
No issues found.
Style & Conventions
No issues found. The f-string quote normalization (outer double, inner single) is a clean incidental fix.
Suggestions
log_time("end", ...)count line logsapi_data[0]["count"] + api_data[1]["count"]— the pre-filter total — not the number of rows actually processed. Once refractor variants exist in production this will overstate the scouting input size in logs. Not a blocker, but worth noting for future observability.Verdict: COMMENT
LGTM. Filter logic is correct and applied consistently across all four fetch paths. Safe to merge.
Automated review by Claude PR Reviewer
Approved via pd-pr
Approved via pd-pr