feat: sort scheduled games by start time instead of hype

Pre-game listings are more intuitive in chronological order than ranked
by pregame importance. LIVE and FINAL keep sorting by Priority desc.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-19 11:05:35 -04:00
parent 7784eaf9ce
commit 61202b2a70
2 changed files with 127 additions and 2 deletions
+9 -2
View File
@@ -76,6 +76,7 @@ def parse_games(scoreboard_data):
"total": total_priority,
},
"Start Time": get_start_time(game),
"Start Time UTC": game.get("startTimeUTC", ""),
"Home Record": format_record(game["homeTeam"]["record"])
if game["gameState"] in ["PRE", "FUT"]
else "N/A",
@@ -98,8 +99,14 @@ def parse_games(scoreboard_data):
}
)
# Sort games based on priority
return sorted(extracted_info, key=lambda x: x["Priority"], reverse=True)
def _sort_key(g):
if g["Game State"] == "PRE":
# Earliest start first — ISO-8601 sorts correctly as a string
return (0, g["Start Time UTC"], 0)
# LIVE / FINAL — highest priority first
return (1, "", -g["Priority"])
return sorted(extracted_info, key=_sort_key)
def get_comeback_bonus(game):