fix: invert matchup scoring so top-ranked teams boost priority
All checks were successful
CI / Lint (push) Successful in 7s
CI / Test (push) Successful in 7s
CI / Build & Push (push) Successful in 19s

Previously league_sequence was summed raw and subtracted, meaning
rank-1 teams received the smallest penalty — directionally correct
but fragile and confusing. Now the rank is inverted (33 - sequence)
so rank 1 contributes 32 quality points and the result is added as
a bonus, making the intent explicit: better matchups = higher hype.
Also renames the breakdown field matchup → matchup_bonus.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-29 19:34:05 -04:00
parent cf0dec3513
commit 9edc9914a3

View File

@@ -60,7 +60,7 @@ def parse_games(scoreboard_data):
"Hype Breakdown": { "Hype Breakdown": {
"base": priority_comps["base"], "base": priority_comps["base"],
"time": priority_comps["time"], "time": priority_comps["time"],
"matchup": priority_comps["matchup"], "matchup_bonus": priority_comps["matchup_bonus"],
"closeness": priority_comps["closeness"], "closeness": priority_comps["closeness"],
"power_play": priority_comps["power_play"], "power_play": priority_comps["power_play"],
"comeback": comeback, "comeback": comeback,
@@ -197,7 +197,7 @@ def _priority_components(game):
_zero = { _zero = {
"base": 0, "base": 0,
"time": 0, "time": 0,
"matchup": 0, "matchup_bonus": 0,
"closeness": 0, "closeness": 0,
"power_play": 0, "power_play": 0,
"total": 0, "total": 0,
@@ -222,17 +222,20 @@ def _priority_components(game):
# ── 2. Period length for time calculations ──────────────────────────── # ── 2. Period length for time calculations ────────────────────────────
period_length = (1200 if is_playoff else 300) if period >= 4 else 1200 period_length = (1200 if is_playoff else 300) if period >= 4 else 1200
# ── 3. Standings-quality matchup adjustment ─────────────────────────── # ── 3. Standings-quality matchup bonus ───────────────────────────────
# Invert rank so that #1 (best) contributes the most quality points.
# league_sequence 1=best, 32=worst → inverted: 32 quality pts for #1, 1 for #32.
home_standings = get_team_standings(game["homeTeam"]["name"]["default"]) home_standings = get_team_standings(game["homeTeam"]["name"]["default"])
away_standings = get_team_standings(game["awayTeam"]["name"]["default"]) away_standings = get_team_standings(game["awayTeam"]["name"]["default"])
home_total = ( home_quality = (33 - home_standings["league_sequence"]) + (
home_standings["league_sequence"] + home_standings["league_l10_sequence"] 33 - home_standings["league_l10_sequence"]
) )
away_total = ( away_quality = (33 - away_standings["league_sequence"]) + (
away_standings["league_sequence"] + away_standings["league_l10_sequence"] 33 - away_standings["league_l10_sequence"]
) )
# Higher period = matchup matters less (any OT is exciting regardless of teams)
matchup_multiplier = {1: 2.0, 2: 1.65, 3: 1.50, 4: 1.0}.get(period, 1.0) matchup_multiplier = {1: 2.0, 2: 1.65, 3: 1.50, 4: 1.0}.get(period, 1.0)
matchup_adjustment = (home_total + away_total) * matchup_multiplier matchup_bonus = (home_quality + away_quality) * matchup_multiplier
# ── 4. Score-differential penalty ──────────────────────────────────── # ── 4. Score-differential penalty ────────────────────────────────────
if score_difference > 3: if score_difference > 3:
@@ -285,17 +288,17 @@ def _priority_components(game):
pp_bonus = 30 pp_bonus = 30
logger.debug( logger.debug(
"priority components — base: %s, time: %.0f, matchup: %.0f, " "priority components — base: %s, time: %.0f, matchup_bonus: %.0f, "
"closeness: %s, pp: %s", "closeness: %s, pp: %s",
base_priority, base_priority,
time_priority, time_priority,
matchup_adjustment, matchup_bonus,
closeness_bonus, closeness_bonus,
pp_bonus, pp_bonus,
) )
final_priority = int( final_priority = int(
base_priority + time_priority - matchup_adjustment + closeness_bonus + pp_bonus base_priority + time_priority + matchup_bonus + closeness_bonus + pp_bonus
) )
# Pushes intermission games to the bottom, retains relative sort order # Pushes intermission games to the bottom, retains relative sort order
@@ -305,7 +308,7 @@ def _priority_components(game):
return { return {
"base": base_priority, "base": base_priority,
"time": int(time_priority), "time": int(time_priority),
"matchup": int(matchup_adjustment), "matchup_bonus": int(matchup_bonus),
"closeness": closeness_bonus, "closeness": closeness_bonus,
"power_play": pp_bonus, "power_play": pp_bonus,
"total": final_priority, "total": final_priority,