Skip to content

Commit facd30b

Browse files
committed
fix: update KenPom data collection logic
Modified the `collect_kenpom_team_metrics` function to handle the "__all__" team key correctly, ensuring it uses a fallback label. Adjusted the `collect_kenpom_fanmatch` function to calculate the season based on the game date, aligning with KenPom's end-year convention for college basketball.
1 parent 586235d commit facd30b

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

odds/src/odds_pipeline/collect_kenpom.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ def collect_kenpom_team_metrics(*, season: int, metric_type: str) -> int:
7070
with connect(settings.database_url) as conn:
7171
with conn.cursor() as cur:
7272
for r in records:
73-
team = str(r.get(team_key) or "__unknown__")
73+
if team_key == "__all__":
74+
# Fallback blob: always use literal team label "__all__"
75+
team = "__all__"
76+
else:
77+
team = str(r.get(team_key) or "__unknown__")
7478
cur.execute(
7579
"""
7680
INSERT INTO raw_kenpom_team_metrics (
@@ -117,6 +121,10 @@ def collect_kenpom_fanmatch(*, game_date: date) -> int:
117121
with connect(settings.database_url) as conn:
118122
with conn.cursor() as cur:
119123
for r in records:
124+
# KenPom seasons use the end-year convention for college hoops.
125+
# Example: games in Nov/Dec 2025 belong to the 2026 season.
126+
season = game_date.year + 1 if game_date.month >= 7 else game_date.year
127+
120128
# FanMatch rows may have matchup/team columns; store under team='__fanmatch__'
121129
cur.execute(
122130
"""
@@ -128,7 +136,7 @@ def collect_kenpom_fanmatch(*, game_date: date) -> int:
128136
ON CONFLICT DO NOTHING
129137
""",
130138
{
131-
"season": int(game_date.year),
139+
"season": int(season),
132140
"team": "__fanmatch__",
133141
"metric_type": "fanmatch",
134142
"collected_at": collected_at,

0 commit comments

Comments
 (0)