14 Commits

3 changed files with 32 additions and 20 deletions

View File

@@ -6,8 +6,8 @@ SCOREBOARD_DATA_FILE = 'app/data/scoreboard_data.json'
def get_scoreboard_data(): def get_scoreboard_data():
now = datetime.now() now = datetime.now()
start_time_evening = now.replace(hour=23, minute=00, second=0, microsecond=0) # 7:00 PM EST start_time_evening = now.replace(hour=19, minute=00, second=0, microsecond=0) # 7:00 PM EST
end_time_evening = now.replace(hour=8, minute=00, second=0, microsecond=0) # 3:00 AM EST end_time_evening = now.replace(hour=2, minute=00, second=0, microsecond=0) # 3:00 AM EST
if now >= start_time_evening or now < end_time_evening: if now >= start_time_evening or now < end_time_evening:
# Use now URL # Use now URL

View File

@@ -58,7 +58,11 @@ def process_time_remaining(game):
def process_start_time(game): def process_start_time(game):
if game["gameState"] in ["PRE", "FUT"]: if game["gameState"] in ["PRE", "FUT"]:
utc_time = game["startTimeUTC"] utc_time = game["startTimeUTC"]
return utc_to_est_time(utc_time) est_time = utc_to_est_time(utc_time)
# Check if the hour starts with a zero
if est_time.startswith("0"):
est_time = est_time[1:] # Drop the leading zero
return est_time
else: else:
return "N/A" return "N/A"
@@ -78,6 +82,14 @@ def calculate_game_priority(game):
# Return 0 if game is in certain states # Return 0 if game is in certain states
if game["gameState"] in ["FINAL", "OFF", "PRE", "FUT"]: if game["gameState"] in ["FINAL", "OFF", "PRE", "FUT"]:
return 0 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 # Get standings for home and away teams
home_team_standings = get_team_standings(game["homeTeam"]["name"]["default"]) home_team_standings = get_team_standings(game["homeTeam"]["name"]["default"])
@@ -88,26 +100,26 @@ def calculate_game_priority(game):
away_total = away_team_standings["league_sequence"] + away_team_standings["league_l10_sequence"] away_total = away_team_standings["league_sequence"] + away_team_standings["league_l10_sequence"]
# Calculate the matchup adjustment factor # Calculate the matchup adjustment factor
matchup_adjustment = home_total + away_total matchup_multiplier = {5: 1, 4: 1, 3: 1.25, 2: 1.50, 1: 2}.get(period)
matchup_adjustment = (home_total + away_total) * matchup_multiplier
# 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
# Calculate the base priority based on period # Calculate the base priority based on period
base_priority = {5: 650, 4: 600, 3: 300, 2: 200}.get(period, 100) base_priority = {5: 650, 4: 600, 3: 300, 2: 200}.get(period, 100)
# Adjust base priority based on score difference # Adjust base priority based on score difference
score_differential_adjustment = 0
if score_difference > 3: if score_difference > 3:
base_priority -= 500 score_differential_adjustment += 500
elif score_difference > 2: elif score_difference > 2:
base_priority -= 350 score_differential_adjustment += 350
elif score_difference > 1: 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 # Adjust base priority based on certain conditions
if score_difference == 0 and period == 3 and time_remaining <= 600: if score_difference == 0 and period == 3 and time_remaining <= 600:
@@ -123,7 +135,7 @@ def calculate_game_priority(game):
# Pushes the games that are in intermission to the bottom, but retains their sort # Pushes the games that are in intermission to the bottom, but retains their sort
if game["clock"]["inIntermission"]: if game["clock"]["inIntermission"]:
return (final_priority - 2000) return (-2000 - time_remaining)
return final_priority return final_priority

View File

@@ -95,17 +95,17 @@ function updateGauge() {
var score = parseInt(gauge.getAttribute('data-score')); var score = parseInt(gauge.getAttribute('data-score'));
// Clamp the score value between 0 and 700 // Clamp the score value between 0 and 700
score = Math.min(700, Math.max(0, score)); score = Math.min(650, Math.max(0, score));
// Calculate the gauge width as a percentage // Calculate the gauge width as a percentage
var gaugeWidth = (score / 700) * 100; var gaugeWidth = (score / 650) * 100;
// Set the width of the gauge // Set the width of the gauge
gauge.style.width = gaugeWidth + '%'; gauge.style.width = gaugeWidth + '%';
if (score <=350) { if (score <=300) {
gauge.style.backgroundColor = '#4A90E2' gauge.style.backgroundColor = '#4A90E2'
} else if (score <= 560) { } else if (score <= 500) {
gauge.style.backgroundColor = '#FF4500' gauge.style.backgroundColor = '#FF4500'
} else { } else {
gauge.style.backgroundColor = '#FF0033' gauge.style.backgroundColor = '#FF0033'