fix: address PR review findings
- CRITICAL: Fix migration FK refs player(id) → player(player_id) - Remove dead is_start flag from pitching groups (no starts column) - Fix hr → homerun in test make_play helper - Add explanatory comment to ruff.toml - Replace print() with logging in seed script Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
da9eaa1692
commit
f7bc248a9f
@ -9,10 +9,13 @@ Can be run standalone:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from app.db_engine import EvolutionTrack
|
from app.db_engine import EvolutionTrack
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
_JSON_PATH = Path(__file__).parent / "evolution_tracks.json"
|
_JSON_PATH = Path(__file__).parent / "evolution_tracks.json"
|
||||||
|
|
||||||
|
|
||||||
@ -50,13 +53,14 @@ def seed_evolution_tracks() -> list[EvolutionTrack]:
|
|||||||
track.save()
|
track.save()
|
||||||
|
|
||||||
action = "created" if created else "updated"
|
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)
|
results.append(track)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print("Seeding evolution tracks...")
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
logger.info("Seeding evolution tracks...")
|
||||||
tracks = seed_evolution_tracks()
|
tracks = seed_evolution_tracks()
|
||||||
print(f"Done. {len(tracks)} track(s) processed.")
|
logger.info("Done. %d track(s) processed.", len(tracks))
|
||||||
|
|||||||
@ -129,7 +129,6 @@ def _build_pitching_groups(plays):
|
|||||||
"saves": 0,
|
"saves": 0,
|
||||||
"holds": 0,
|
"holds": 0,
|
||||||
"blown_saves": 0,
|
"blown_saves": 0,
|
||||||
"is_start": False,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -176,7 +175,6 @@ def _apply_decisions(pitching_groups, decisions):
|
|||||||
"saves": 0,
|
"saves": 0,
|
||||||
"holds": 0,
|
"holds": 0,
|
||||||
"blown_saves": 0,
|
"blown_saves": 0,
|
||||||
"is_start": False,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g = pitching_groups[key]
|
g = pitching_groups[key]
|
||||||
@ -185,8 +183,6 @@ def _apply_decisions(pitching_groups, decisions):
|
|||||||
g["saves"] += decision.is_save
|
g["saves"] += decision.is_save
|
||||||
g["holds"] += decision.hold
|
g["holds"] += decision.hold
|
||||||
g["blown_saves"] += decision.b_save
|
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):
|
def _upsert_postgres(player_id, team_id, season, game_id, batting, pitching):
|
||||||
|
|||||||
@ -34,7 +34,7 @@ BEGIN;
|
|||||||
-- --------------------------------------------
|
-- --------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS player_season_stats (
|
CREATE TABLE IF NOT EXISTS player_season_stats (
|
||||||
id SERIAL PRIMARY KEY,
|
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,
|
team_id INTEGER NOT NULL REFERENCES team(id) ON DELETE CASCADE,
|
||||||
season INTEGER NOT NULL,
|
season INTEGER NOT NULL,
|
||||||
-- Batting stats
|
-- Batting stats
|
||||||
@ -108,7 +108,7 @@ CREATE TABLE IF NOT EXISTS evolution_track (
|
|||||||
-- --------------------------------------------
|
-- --------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS evolution_card_state (
|
CREATE TABLE IF NOT EXISTS evolution_card_state (
|
||||||
id SERIAL PRIMARY KEY,
|
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,
|
team_id INTEGER NOT NULL REFERENCES team(id) ON DELETE CASCADE,
|
||||||
track_id INTEGER NOT NULL REFERENCES evolution_track(id) ON DELETE CASCADE,
|
track_id INTEGER NOT NULL REFERENCES evolution_track(id) ON DELETE CASCADE,
|
||||||
current_tier INTEGER NOT NULL DEFAULT 0,
|
current_tier INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|||||||
@ -1,2 +1,3 @@
|
|||||||
[lint]
|
[lint]
|
||||||
|
# db_engine.py uses `from peewee import *` intentionally — suppress star-import warnings
|
||||||
ignore = ["F403", "F405"]
|
ignore = ["F403", "F405"]
|
||||||
|
|||||||
@ -121,7 +121,6 @@ def make_play(game, play_num, batter, batter_team, pitcher, pitcher_team, **stat
|
|||||||
ab=0,
|
ab=0,
|
||||||
hit=0,
|
hit=0,
|
||||||
run=0,
|
run=0,
|
||||||
hr=0,
|
|
||||||
double=0,
|
double=0,
|
||||||
triple=0,
|
triple=0,
|
||||||
homerun=0,
|
homerun=0,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user