|
|
|
|
@@ -79,6 +79,14 @@ def calculate_game_priority(game):
|
|
|
|
|
if game["gameState"] in ["FINAL", "OFF", "PRE", "FUT"]:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
# Get period, time remaining, scores, and other relevant data
|
|
|
|
|
period = game.get("periodDescriptor", {}).get("number", 0)
|
|
|
|
|
time_remaining = game.get("clock", {}).get("secondsRemaining", 0)
|
|
|
|
|
home_score = game["homeTeam"]["score"]
|
|
|
|
|
away_score = game["awayTeam"]["score"]
|
|
|
|
|
score_difference = abs(home_score - away_score)
|
|
|
|
|
score_total = (home_score + away_score) * 20
|
|
|
|
|
|
|
|
|
|
# Get standings for home and away teams
|
|
|
|
|
home_team_standings = get_team_standings(game["homeTeam"]["name"]["default"])
|
|
|
|
|
away_team_standings = get_team_standings(game["awayTeam"]["name"]["default"])
|
|
|
|
|
@@ -88,26 +96,26 @@ def calculate_game_priority(game):
|
|
|
|
|
away_total = away_team_standings["league_sequence"] + away_team_standings["league_l10_sequence"]
|
|
|
|
|
|
|
|
|
|
# Calculate the matchup adjustment factor
|
|
|
|
|
matchup_adjustment = home_total + away_total
|
|
|
|
|
|
|
|
|
|
# Get period, time remaining, scores, and other relevant data
|
|
|
|
|
period = game.get("periodDescriptor", {}).get("number", 0)
|
|
|
|
|
time_remaining = game.get("clock", {}).get("secondsRemaining", 0)
|
|
|
|
|
home_score = game["homeTeam"]["score"]
|
|
|
|
|
away_score = game["awayTeam"]["score"]
|
|
|
|
|
score_difference = abs(home_score - away_score)
|
|
|
|
|
score_total = (home_score + away_score) * 25
|
|
|
|
|
matchup_multiplier = {5: 1, 4: 1, 3: 1.25, 2: 1.50, 1: 2}.get(period)
|
|
|
|
|
matchup_adjustment = (home_total + away_total) * matchup_multiplier
|
|
|
|
|
|
|
|
|
|
# Calculate the base priority based on period
|
|
|
|
|
base_priority = {5: 650, 4: 600, 3: 300, 2: 200}.get(period, 100)
|
|
|
|
|
|
|
|
|
|
# Adjust base priority based on score difference
|
|
|
|
|
score_differential_adjustment = 0
|
|
|
|
|
|
|
|
|
|
if score_difference > 3:
|
|
|
|
|
base_priority -= 500
|
|
|
|
|
score_differential_adjustment += 500
|
|
|
|
|
elif score_difference > 2:
|
|
|
|
|
base_priority -= 350
|
|
|
|
|
score_differential_adjustment += 350
|
|
|
|
|
elif score_difference > 1:
|
|
|
|
|
base_priority -= 100
|
|
|
|
|
score_differential_adjustment += 100
|
|
|
|
|
|
|
|
|
|
if period == 3 and time_remaining <= 300:
|
|
|
|
|
score_differential_adjustment = score_differential_adjustment * 2
|
|
|
|
|
|
|
|
|
|
base_priority -= score_differential_adjustment
|
|
|
|
|
|
|
|
|
|
# Adjust base priority based on certain conditions
|
|
|
|
|
if score_difference == 0 and period == 3 and time_remaining <= 600:
|
|
|
|
|
@@ -123,7 +131,7 @@ def calculate_game_priority(game):
|
|
|
|
|
|
|
|
|
|
# Pushes the games that are in intermission to the bottom, but retains their sort
|
|
|
|
|
if game["clock"]["inIntermission"]:
|
|
|
|
|
return (final_priority - 2000)
|
|
|
|
|
return (-2000 - time_remaining)
|
|
|
|
|
|
|
|
|
|
return final_priority
|
|
|
|
|
|
|
|
|
|
|