diff --git a/app/seed/evolution_tracks.py b/app/seed/evolution_tracks.py index 3875a95..3314a97 100644 --- a/app/seed/evolution_tracks.py +++ b/app/seed/evolution_tracks.py @@ -9,10 +9,13 @@ Can be run standalone: """ import json +import logging from pathlib import Path from app.db_engine import EvolutionTrack +logger = logging.getLogger(__name__) + _JSON_PATH = Path(__file__).parent / "evolution_tracks.json" @@ -50,13 +53,14 @@ def seed_evolution_tracks() -> list[EvolutionTrack]: track.save() action = "created" if created else "updated" - print(f" [{action}] {track.name} (card_type={track.card_type})") + logger.info("[%s] %s (card_type=%s)", action, track.name, track.card_type) results.append(track) return results if __name__ == "__main__": - print("Seeding evolution tracks...") + logging.basicConfig(level=logging.INFO) + logger.info("Seeding evolution tracks...") tracks = seed_evolution_tracks() - print(f"Done. {len(tracks)} track(s) processed.") + logger.info("Done. %d track(s) processed.", len(tracks)) diff --git a/app/services/season_stats.py b/app/services/season_stats.py index 0223965..46d7e13 100644 --- a/app/services/season_stats.py +++ b/app/services/season_stats.py @@ -129,7 +129,6 @@ def _build_pitching_groups(plays): "saves": 0, "holds": 0, "blown_saves": 0, - "is_start": False, } ) @@ -176,7 +175,6 @@ def _apply_decisions(pitching_groups, decisions): "saves": 0, "holds": 0, "blown_saves": 0, - "is_start": False, } g = pitching_groups[key] @@ -185,8 +183,6 @@ def _apply_decisions(pitching_groups, decisions): g["saves"] += decision.is_save g["holds"] += decision.hold g["blown_saves"] += decision.b_save - if decision.is_start: - g["is_start"] = True def _upsert_postgres(player_id, team_id, season, game_id, batting, pitching): diff --git a/migrations/2026-03-17_add_evolution_tables.sql b/migrations/2026-03-17_add_evolution_tables.sql index 8aedac3..5ab57aa 100644 --- a/migrations/2026-03-17_add_evolution_tables.sql +++ b/migrations/2026-03-17_add_evolution_tables.sql @@ -34,7 +34,7 @@ BEGIN; -- -------------------------------------------- CREATE TABLE IF NOT EXISTS player_season_stats ( id SERIAL PRIMARY KEY, - player_id INTEGER NOT NULL REFERENCES player(id) ON DELETE CASCADE, + player_id INTEGER NOT NULL REFERENCES player(player_id) ON DELETE CASCADE, team_id INTEGER NOT NULL REFERENCES team(id) ON DELETE CASCADE, season INTEGER NOT NULL, -- Batting stats @@ -108,7 +108,7 @@ CREATE TABLE IF NOT EXISTS evolution_track ( -- -------------------------------------------- CREATE TABLE IF NOT EXISTS evolution_card_state ( id SERIAL PRIMARY KEY, - player_id INTEGER NOT NULL REFERENCES player(id) ON DELETE CASCADE, + player_id INTEGER NOT NULL REFERENCES player(player_id) ON DELETE CASCADE, team_id INTEGER NOT NULL REFERENCES team(id) ON DELETE CASCADE, track_id INTEGER NOT NULL REFERENCES evolution_track(id) ON DELETE CASCADE, current_tier INTEGER NOT NULL DEFAULT 0, diff --git a/ruff.toml b/ruff.toml index 8f64624..0dbfb5e 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,2 +1,3 @@ [lint] +# db_engine.py uses `from peewee import *` intentionally — suppress star-import warnings ignore = ["F403", "F405"] diff --git a/tests/test_season_stats_update.py b/tests/test_season_stats_update.py index 94f40e5..cfa0dcf 100644 --- a/tests/test_season_stats_update.py +++ b/tests/test_season_stats_update.py @@ -121,7 +121,6 @@ def make_play(game, play_num, batter, batter_team, pitcher, pitcher_team, **stat ab=0, hit=0, run=0, - hr=0, double=0, triple=0, homerun=0,