Merge pull request 'feat: add REFRACTOR_START_SEASON floor to evaluator queries (#195)' (#209) from issue/195-docs-document-cross-season-stat-accumulation-decis into main

This commit is contained in:
cal 2026-04-08 13:25:48 +00:00
commit 5ff11759f9
2 changed files with 9 additions and 2 deletions

View File

@ -44,6 +44,10 @@ else:
pragmas={"journal_mode": "wal", "cache_size": -1 * 64000, "synchronous": 0},
)
# Refractor stat accumulation starts at this season — stats from earlier seasons
# are excluded from evaluation queries. Override via REFRACTOR_START_SEASON env var.
REFRACTOR_START_SEASON = int(os.environ.get("REFRACTOR_START_SEASON", "11"))
# 2025, 2005
ranked_cardsets = [24, 25, 26, 27, 28, 29]
LIVE_CARDSET_ID = 27

View File

@ -148,10 +148,11 @@ def evaluate_card(
strikeouts=sum(r.strikeouts for r in rows),
)
else:
from app.db_engine import (
from app.db_engine import ( # noqa: PLC0415
BattingSeasonStats,
PitchingSeasonStats,
) # noqa: PLC0415
REFRACTOR_START_SEASON,
)
card_type = card_state.track.card_type
if card_type == "batter":
@ -159,6 +160,7 @@ def evaluate_card(
BattingSeasonStats.select().where(
(BattingSeasonStats.player == player_id)
& (BattingSeasonStats.team == team_id)
& (BattingSeasonStats.season >= REFRACTOR_START_SEASON)
)
)
totals = _CareerTotals(
@ -175,6 +177,7 @@ def evaluate_card(
PitchingSeasonStats.select().where(
(PitchingSeasonStats.player == player_id)
& (PitchingSeasonStats.team == team_id)
& (PitchingSeasonStats.season >= REFRACTOR_START_SEASON)
)
)
totals = _CareerTotals(