24 Commits

Author SHA1 Message Date
b10736d43c merge develop into main for v4.1.9 (#44) 2024-03-11 12:38:28 -04:00
8913b40a8c hotfix: correct for dst 2024-03-11 12:37:19 -04:00
daabae1e49 fix: add shootout indicator 2024-02-25 01:17:04 -05:00
53a0fc7993 merge develop into main for v4.1.8 (#43) 2024-02-22 23:05:25 -05:00
a1352869ad fix: adjust game score calculation 2024-02-22 23:04:49 -05:00
f059d4228b fix: raise gauge ceiling to 700 2024-02-22 23:04:38 -05:00
c8f535ee48 fix: record sizes are now consistent (#42) 2024-02-22 02:16:39 -05:00
65369896cc fix: record sizes are now consistent 2024-02-22 02:16:12 -05:00
7e41cf4781 fix: correct date crossover time (#41) 2024-02-22 02:09:28 -05:00
20ffd05df1 fix: correct date crossover time 2024-02-22 02:08:56 -05:00
2e85ced6ce fix: drop leading zero for scheduled games (#40) 2024-02-22 02:06:34 -05:00
5d65533ff5 fix: drop leading zero for scheduled games 2024-02-22 02:06:15 -05:00
085514ab16 fix: change date crossover to 3:00 am ETC (#39) 2024-02-22 02:01:01 -05:00
960ff6e5ac fix: change date crossover to 3:00 am ETC 2024-02-22 02:00:39 -05:00
04e29469dd fix: adjust scoreboard time (#38) 2024-02-22 01:57:10 -05:00
360188114e fix: adjust scoreboard time 2024-02-22 01:56:46 -05:00
982fdfb3c1 merge develop into main for v4.1.2 (#37) 2024-02-22 01:17:52 -05:00
94f9cced2e game priority: double differential adjustment at 5 minutes left in third 2024-02-22 01:17:13 -05:00
3edb84c333 fix: change scale to 650 instead of 600 2024-02-22 01:16:31 -05:00
6ec9a7aef1 fix: lower weight of total score 2024-02-22 00:14:39 -05:00
dfb86f6fd5 changes hype meter scale to 600 instead of 700 2024-02-22 00:14:14 -05:00
e5824cefc5 fix: sort games in intermission by time left 2024-02-22 00:11:22 -05:00
18ff48cc2c feat: add matchup adjustment scaling. Earlier the period, the heavier… (#36) 2024-02-21 23:52:44 -05:00
8c5de8602f feat: add matchup adjustment scaling. Earlier the period, the heavier we way the matchup strength 2024-02-21 23:52:06 -05:00
3 changed files with 63 additions and 25 deletions

View File

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

View File

@@ -1,6 +1,14 @@
import sqlite3
from datetime import datetime, timedelta
def process_record(record):
if record == "N/A":
return "N/A"
else:
parts = record.split("-")
formatted_parts = [part.zfill(2) for part in parts]
return "-".join(formatted_parts)
def extract_game_info(scoreboard_data):
if not scoreboard_data:
return []
@@ -22,8 +30,8 @@ def extract_game_info(scoreboard_data):
"Intermission": game["clock"]["inIntermission"] if game_state == "LIVE" else "N/A",
"Priority": calculate_game_priority(game),
"Start Time": process_start_time(game),
"Home Record": game["homeTeam"]["record"] if game["gameState"] in ["PRE", "FUT"] else "N/A",
"Away Record": game["awayTeam"]["record"] if game["gameState"] in ["PRE", "FUT"] else "N/A",
"Home Record": process_record(game["homeTeam"]["record"]) if game["gameState"] in ["PRE", "FUT"] else "N/A",
"Away Record": process_record(game["awayTeam"]["record"]) if game["gameState"] in ["PRE", "FUT"] else "N/A",
"Home Shots": game["homeTeam"]["sog"] if game["gameState"] not in ["PRE", "FUT"] else 0,
"Away Shots": game["awayTeam"]["sog"] if game["gameState"] not in ["PRE", "FUT"] else 0,
"Home Power Play": get_power_play_info(game, game["homeTeam"]["name"]["default"]),
@@ -58,7 +66,11 @@ def process_time_remaining(game):
def process_start_time(game):
if game["gameState"] in ["PRE", "FUT"]:
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:
return "N/A"
@@ -79,6 +91,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,42 +108,57 @@ 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.50, 2: 1.65, 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)
base_priority = {5: 650, 4: 600, 3: 300, 2: 200}.get(period, 150)
# 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:
if period == 3 and time_remaining <= 720:
if score_difference == 0:
base_priority += 100
elif score_difference == 1:
base_priority += 60
if period == 3 and time_remaining <= 360:
if score_difference == 0:
base_priority += 50
elif score_difference == 1:
base_priority += 30
# Calculate time priority
time_multiplier = {4: 2, 3: 2, 2: 1.5}.get(period, 0.75)
time_priority = ((1200 - time_remaining) / 20) * time_multiplier
print(base_priority)
print(time_priority)
print(matchup_adjustment)
print(score_total)
# Calculate the final priority
final_priority = int(base_priority + time_priority - matchup_adjustment + score_total)
# 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
@@ -141,6 +176,6 @@ def get_team_standings(team_name):
def utc_to_est_time(utc_time):
utc_datetime = datetime.strptime(utc_time, "%Y-%m-%dT%H:%M:%SZ")
est_offset = timedelta(hours=-5)
est_offset = timedelta(hours=-4)
est_datetime = utc_datetime + est_offset
return est_datetime.strftime("%#I:%M %p")

View File

@@ -103,9 +103,9 @@ function updateGauge() {
// Set the width of the gauge
gauge.style.width = gaugeWidth + '%';
if (score <=350) {
if (score <=300) {
gauge.style.backgroundColor = '#4A90E2'
} else if (score <= 560) {
} else if (score <= 550) {
gauge.style.backgroundColor = '#FF4500'
} else {
gauge.style.backgroundColor = '#FF0033'
@@ -166,9 +166,12 @@ function generateGameBoxes(games, state) {
else if (game['Period'] == 3 ) {
html += '3rd';
}
else {
else if (game['Period'] == 4 ) {
html += 'OT';
}
else {
html += 'SO';
}
html += '</div>';
html += '<div class="live-time">' + game['Time Remaining'] + '</div>';
}