From 8c5de8602f2f28d5f757fdfd7d36c7f106d209c1 Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Wed, 21 Feb 2024 23:52:06 -0500 Subject: [PATCH] feat: add matchup adjustment scaling. Earlier the period, the heavier we way the matchup strength --- app/scoreboard/process_data.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/scoreboard/process_data.py b/app/scoreboard/process_data.py index dc35993..761bbef 100644 --- a/app/scoreboard/process_data.py +++ b/app/scoreboard/process_data.py @@ -78,6 +78,14 @@ def calculate_game_priority(game): # Return 0 if game is in certain states 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) * 25 # Get standings for home and away teams home_team_standings = get_team_standings(game["homeTeam"]["name"]["default"]) @@ -88,15 +96,8 @@ 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)