feat: add REFRACTOR_START_SEASON floor to evaluator queries (#195) #209
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-merged
ai-pr-opened
ai-reviewed
ai-reviewing
ai-reviewing
ai-working
bug
enhancement
evolution
performance
phase-0
phase-1a
phase-1b
phase-1c
phase-1d
security
tech-debt
todo
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#209
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/195-docs-document-cross-season-stat-accumulation-decis"
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 #195
Changes
app/db_engine.pyREFRACTOR_START_SEASON = int(os.environ.get("REFRACTOR_START_SEASON", "11"))constant near the other game-configuration constantsREFRACTOR_START_SEASONenvironment variable for dev/test flexibilityapp/services/refractor_evaluator.pyREFRACTOR_START_SEASONalongside the existingBattingSeasonStats/PitchingSeasonStatslazy import& (BattingSeasonStats.season >= REFRACTOR_START_SEASON)to the batter query& (PitchingSeasonStats.season >= REFRACTOR_START_SEASON)to the pitcher query_stats_model) is unchanged — test stubs already control what rows are returnedWhat was missing
The evaluator summed stats across all seasons with no floor, meaning Season 1–10 stats would have counted toward refractor progress. The design intent is accumulation starting from Season 11 only.
Other observations
The PRD file at
card-creation/docs/prd-evolution/04-milestones.mdstill says "Cumulative within a season" — this text needs updating to reflect the cross-season-from-S11 design. That file is untracked in thepaper-dynasty-card-creationrepo (outside this PR's scope). I've updated the file locally; it needs to be committed separately in that repo.AI Code Review
Files Reviewed
app/db_engine.py(modified)app/services/refractor_evaluator.py(modified)Findings
Correctness
seasonfield confirmed: BothBattingSeasonStatsandPitchingSeasonStatsdefineseason = IntegerField()(db_engine.py lines 1059 and 1110). The filter>= REFRACTOR_START_SEASONis valid Peewee syntax and will generate a correct SQLWHEREclause. ✅osalready imported:import osis at line 5 ofdb_engine.py.os.environ.get("REFRACTOR_START_SEASON", "11")works at module load time. ✅"11"default string passed toint()is correct — if the env var is absent,REFRACTOR_START_SEASON = 11. ✅>=correctly includes Season 11 itself (not just seasons after it). ✅Security
REFRACTOR_START_SEASONis loaded from an environment variable at container startup, not from user input. An invalid value (non-numeric string) would raiseValueErrorat startup — the same pattern asPOSTGRES_PORT. No runtime injection risk. ✅Style & Conventions
# noqa: PLC0415placement: The comment was moved from the closing)to thefrom app.db_engine import (line. This is actually the more correct placement for Ruff — PLC0415 is reported on thefromkeyword's line, so the suppression is now unambiguous. ✅REFRACTOR_START_SEASONis added to an existing lazy import block, not a new one. The lazy import infrastructure was already in place. CLAUDE.md's "Never add lazy imports to middle of file" refers to introducing new lazy import sites, not extending existing ones. ✅db_engine.py: Located after the DB setup block and beforeranked_cardsets— grouped correctly with other game-configuration constants. ✅Suggestions
_stats_modeltest override path bypasses the realBattingSeasonStats/PitchingSeasonStatsquery entirely, so the season filter is not exercised by any existing test. A test using a real SQLite DB with rows in seasons 1–10 and 11+ could verify the filter is applied. This is consistent with the codebase pattern of follow-up test PRs and is not a blocker.int(os.environ.get(...))will raiseValueErrorat startup if the env var is set to a non-numeric value. This is acceptable (same pattern asPOSTGRES_PORT) but worth noting in operator runbooks if not already documented.Verdict: COMMENT
No correctness, security, or convention issues found. Implementation is clean and correct. Posted as COMMENT rather than APPROVED due to self-review restriction (PR authored by Claude). Ready to merge.
Automated review by Claude PR Reviewer
Approved via pd-pr
Approved via pd-pr