feat: game importance factor in hype scoring
Adds calculate_game_importance() that boosts Priority for high-stakes regular-season matchups based on season progress (sharp ramp after game 55), playoff bubble proximity (wildcard rank ~17-19 = max relevance), and divisional/conference rivalry (1.4x/1.2x multipliers). Max bonus 150 pts applied to both LIVE and PRE games; playoff and FINAL games are unaffected. Extends standings schema with division, conference, games_played, and wildcard_sequence fields fetched from the NHL API. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,12 +14,31 @@ def create_standings_table(conn):
|
||||
CREATE TABLE IF NOT EXISTS standings (
|
||||
team_common_name TEXT,
|
||||
league_sequence INTEGER,
|
||||
league_l10_sequence INTEGER
|
||||
league_l10_sequence INTEGER,
|
||||
division_abbrev TEXT,
|
||||
conference_abbrev TEXT,
|
||||
games_played INTEGER,
|
||||
wildcard_sequence INTEGER
|
||||
)
|
||||
""")
|
||||
conn.commit()
|
||||
|
||||
|
||||
def migrate_standings_table(conn):
|
||||
cursor = conn.cursor()
|
||||
for col_name, col_type in [
|
||||
("division_abbrev", "TEXT"),
|
||||
("conference_abbrev", "TEXT"),
|
||||
("games_played", "INTEGER"),
|
||||
("wildcard_sequence", "INTEGER"),
|
||||
]:
|
||||
try:
|
||||
cursor.execute(f"ALTER TABLE standings ADD COLUMN {col_name} {col_type}")
|
||||
conn.commit()
|
||||
except sqlite3.OperationalError:
|
||||
pass # Column already exists
|
||||
|
||||
|
||||
def truncate_standings_table(conn):
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("DELETE FROM standings")
|
||||
@@ -31,13 +50,20 @@ def insert_standings(conn, standings):
|
||||
for team in standings:
|
||||
cursor.execute(
|
||||
"""
|
||||
INSERT INTO standings (team_common_name, league_sequence, league_l10_sequence)
|
||||
VALUES (?, ?, ?)
|
||||
INSERT INTO standings (
|
||||
team_common_name, league_sequence, league_l10_sequence,
|
||||
division_abbrev, conference_abbrev, games_played, wildcard_sequence
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
team["team_common_name"],
|
||||
team["league_sequence"],
|
||||
team["league_l10_sequence"],
|
||||
team["division_abbrev"],
|
||||
team["conference_abbrev"],
|
||||
team["games_played"],
|
||||
team["wildcard_sequence"],
|
||||
),
|
||||
)
|
||||
conn.commit()
|
||||
@@ -56,6 +82,10 @@ def fetch_standings():
|
||||
"team_common_name": team["teamCommonName"]["default"],
|
||||
"league_sequence": team["leagueSequence"],
|
||||
"league_l10_sequence": team["leagueL10Sequence"],
|
||||
"division_abbrev": team["divisionAbbrev"],
|
||||
"conference_abbrev": team["conferenceAbbrev"],
|
||||
"games_played": team["gamesPlayed"],
|
||||
"wildcard_sequence": team["wildcardSequence"],
|
||||
}
|
||||
)
|
||||
return standings
|
||||
@@ -67,6 +97,7 @@ def fetch_standings():
|
||||
def refresh_standings():
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
create_standings_table(conn)
|
||||
migrate_standings_table(conn)
|
||||
standings = fetch_standings()
|
||||
if standings:
|
||||
truncate_standings_table(conn)
|
||||
|
||||
Reference in New Issue
Block a user