fix: invert matchup scoring so top-ranked teams boost priority
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:
27
app/games.py
27
app/games.py
@@ -60,7 +60,7 @@ def parse_games(scoreboard_data):
|
||||
"Hype Breakdown": {
|
||||
"base": priority_comps["base"],
|
||||
"time": priority_comps["time"],
|
||||
"matchup": priority_comps["matchup"],
|
||||
"matchup_bonus": priority_comps["matchup_bonus"],
|
||||
"closeness": priority_comps["closeness"],
|
||||
"power_play": priority_comps["power_play"],
|
||||
"comeback": comeback,
|
||||
@@ -197,7 +197,7 @@ def _priority_components(game):
|
||||
_zero = {
|
||||
"base": 0,
|
||||
"time": 0,
|
||||
"matchup": 0,
|
||||
"matchup_bonus": 0,
|
||||
"closeness": 0,
|
||||
"power_play": 0,
|
||||
"total": 0,
|
||||
@@ -222,17 +222,20 @@ def _priority_components(game):
|
||||
# ── 2. Period length for time calculations ────────────────────────────
|
||||
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"])
|
||||
away_standings = get_team_standings(game["awayTeam"]["name"]["default"])
|
||||
home_total = (
|
||||
home_standings["league_sequence"] + home_standings["league_l10_sequence"]
|
||||
home_quality = (33 - home_standings["league_sequence"]) + (
|
||||
33 - home_standings["league_l10_sequence"]
|
||||
)
|
||||
away_total = (
|
||||
away_standings["league_sequence"] + away_standings["league_l10_sequence"]
|
||||
away_quality = (33 - away_standings["league_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_adjustment = (home_total + away_total) * matchup_multiplier
|
||||
matchup_bonus = (home_quality + away_quality) * matchup_multiplier
|
||||
|
||||
# ── 4. Score-differential penalty ────────────────────────────────────
|
||||
if score_difference > 3:
|
||||
@@ -285,17 +288,17 @@ def _priority_components(game):
|
||||
pp_bonus = 30
|
||||
|
||||
logger.debug(
|
||||
"priority components — base: %s, time: %.0f, matchup: %.0f, "
|
||||
"priority components — base: %s, time: %.0f, matchup_bonus: %.0f, "
|
||||
"closeness: %s, pp: %s",
|
||||
base_priority,
|
||||
time_priority,
|
||||
matchup_adjustment,
|
||||
matchup_bonus,
|
||||
closeness_bonus,
|
||||
pp_bonus,
|
||||
)
|
||||
|
||||
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
|
||||
@@ -305,7 +308,7 @@ def _priority_components(game):
|
||||
return {
|
||||
"base": base_priority,
|
||||
"time": int(time_priority),
|
||||
"matchup": int(matchup_adjustment),
|
||||
"matchup_bonus": int(matchup_bonus),
|
||||
"closeness": closeness_bonus,
|
||||
"power_play": pp_bonus,
|
||||
"total": final_priority,
|
||||
|
||||
Reference in New Issue
Block a user