Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b10736d43c | |||
| 8913b40a8c | |||
| daabae1e49 | |||
| 53a0fc7993 | |||
| a1352869ad | |||
| f059d4228b | |||
| c8f535ee48 | |||
| 65369896cc | |||
| 7e41cf4781 | |||
| 20ffd05df1 | |||
| 2e85ced6ce | |||
| 5d65533ff5 | |||
| 085514ab16 | |||
| 960ff6e5ac | |||
| 04e29469dd | |||
| 360188114e | |||
| 982fdfb3c1 | |||
| 94f9cced2e | |||
| 3edb84c333 | |||
| 6ec9a7aef1 | |||
| dfb86f6fd5 | |||
| e5824cefc5 | |||
| 18ff48cc2c | |||
| 8c5de8602f | |||
| 9f4a6c966a | |||
| 4da3c2dfdd | |||
| 07ff5ac055 | |||
| fe7449537b | |||
| dd8d1ca12b |
@@ -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=3, 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
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
from datetime import datetime, timedelta
|
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):
|
def extract_game_info(scoreboard_data):
|
||||||
if not scoreboard_data:
|
if not scoreboard_data:
|
||||||
return []
|
return []
|
||||||
@@ -22,8 +30,8 @@ def extract_game_info(scoreboard_data):
|
|||||||
"Intermission": game["clock"]["inIntermission"] if game_state == "LIVE" else "N/A",
|
"Intermission": game["clock"]["inIntermission"] if game_state == "LIVE" else "N/A",
|
||||||
"Priority": calculate_game_priority(game),
|
"Priority": calculate_game_priority(game),
|
||||||
"Start Time": process_start_time(game),
|
"Start Time": process_start_time(game),
|
||||||
"Home Record": game["homeTeam"]["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": game["awayTeam"]["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,
|
"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,
|
"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"]),
|
"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):
|
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"
|
||||||
|
|
||||||
@@ -76,9 +88,17 @@ def get_game_outcome(game, game_state):
|
|||||||
|
|
||||||
def calculate_game_priority(game):
|
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"] or game["clock"]["inIntermission"]:
|
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"])
|
||||||
away_team_standings = get_team_standings(game["awayTeam"]["name"]["default"])
|
away_team_standings = get_team_standings(game["awayTeam"]["name"]["default"])
|
||||||
@@ -88,39 +108,58 @@ 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.50, 2: 1.65, 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, 150)
|
||||||
|
|
||||||
# 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 period == 3 and time_remaining <= 720:
|
||||||
|
if score_difference == 0:
|
||||||
base_priority += 100
|
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
|
# Calculate time priority
|
||||||
time_multiplier = {4: 2, 3: 2, 2: 1.5}.get(period, 0.75)
|
time_multiplier = {4: 2, 3: 2, 2: 1.5}.get(period, 0.75)
|
||||||
|
|
||||||
time_priority = ((1200 - time_remaining) / 20) * time_multiplier
|
time_priority = ((1200 - time_remaining) / 20) * time_multiplier
|
||||||
|
|
||||||
|
print(base_priority)
|
||||||
|
print(time_priority)
|
||||||
|
print(matchup_adjustment)
|
||||||
|
print(score_total)
|
||||||
|
|
||||||
# Calculate the final priority
|
# Calculate the final priority
|
||||||
final_priority = int(base_priority + time_priority - matchup_adjustment + score_total)
|
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 (-2000 - time_remaining)
|
||||||
|
|
||||||
return final_priority
|
return final_priority
|
||||||
|
|
||||||
def get_team_standings(team_name):
|
def get_team_standings(team_name):
|
||||||
@@ -137,6 +176,6 @@ def get_team_standings(team_name):
|
|||||||
|
|
||||||
def utc_to_est_time(utc_time):
|
def utc_to_est_time(utc_time):
|
||||||
utc_datetime = datetime.strptime(utc_time, "%Y-%m-%dT%H:%M:%SZ")
|
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
|
est_datetime = utc_datetime + est_offset
|
||||||
return est_datetime.strftime("%#I:%M %p")
|
return est_datetime.strftime("%#I:%M %p")
|
||||||
|
|||||||
@@ -103,9 +103,9 @@ function updateGauge() {
|
|||||||
// 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 <= 550) {
|
||||||
gauge.style.backgroundColor = '#FF4500'
|
gauge.style.backgroundColor = '#FF4500'
|
||||||
} else {
|
} else {
|
||||||
gauge.style.backgroundColor = '#FF0033'
|
gauge.style.backgroundColor = '#FF0033'
|
||||||
@@ -166,9 +166,12 @@ function generateGameBoxes(games, state) {
|
|||||||
else if (game['Period'] == 3 ) {
|
else if (game['Period'] == 3 ) {
|
||||||
html += '3rd';
|
html += '3rd';
|
||||||
}
|
}
|
||||||
else {
|
else if (game['Period'] == 4 ) {
|
||||||
html += 'OT';
|
html += 'OT';
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
html += 'SO';
|
||||||
|
}
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '<div class="live-time">' + game['Time Remaining'] + '</div>';
|
html += '<div class="live-time">' + game['Time Remaining'] + '</div>';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ body {
|
|||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 15px;
|
margin-top: 0.8%;
|
||||||
margin-bottom: 25px;
|
margin-bottom: 1.5%;
|
||||||
color: #f2f2f2;
|
color: #f2f2f2;
|
||||||
font-size: 2em;
|
font-size: 2.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scoreboard {
|
.scoreboard {
|
||||||
@@ -26,7 +26,7 @@ h1 {
|
|||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
padding: 1%;
|
padding: 1%;
|
||||||
width: 16%;
|
width: 16%;
|
||||||
max-width: 300px;
|
max-width: 350px;
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-left: 1%;
|
margin-left: 1%;
|
||||||
margin-right: 1%;
|
margin-right: 1%;
|
||||||
@@ -52,7 +52,7 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.team-name {
|
.team-name {
|
||||||
font-size: 90%;
|
font-size: 1rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,13 +64,13 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.team-score {
|
.team-score {
|
||||||
font-size: 130%;
|
font-size: 1.35rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.team-record {
|
.team-record {
|
||||||
font-size: 0.75rem;
|
font-size: 0.8rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.team-sog {
|
.team-sog {
|
||||||
font-size: 65%;
|
font-size: 0.75rem;
|
||||||
color: #ddd;
|
color: #ddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,12 +125,12 @@ h1 {
|
|||||||
background-color: #444;
|
background-color: #444;
|
||||||
padding: 1.5%;
|
padding: 1.5%;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
font-size: 0.65rem;
|
font-size: 0.75rem;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-weight: bolder;
|
font-weight: bolder;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
width: auto;
|
width: auto;
|
||||||
height: 10%;
|
height: 7%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -150,12 +150,15 @@ h1 {
|
|||||||
background-color: #444;
|
background-color: #444;
|
||||||
padding: 1.5%;
|
padding: 1.5%;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
font-size: 65%;
|
font-size: 0.7rem;
|
||||||
color: #ddd;
|
color: #ddd;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
width: auto;
|
width: auto;
|
||||||
height: 7.5%;
|
height: 7%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.live-state {
|
.live-state {
|
||||||
@@ -165,12 +168,12 @@ h1 {
|
|||||||
background-color: #0b6e31;
|
background-color: #0b6e31;
|
||||||
padding: 1.5%;
|
padding: 1.5%;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
font-size: 80%;
|
font-size: 0.72rem;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-weight: bolder;
|
font-weight: bolder;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
width: 7.2%;
|
width: 7%;
|
||||||
height: 7.5%;
|
height: 7%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -179,23 +182,23 @@ h1 {
|
|||||||
.live-time {
|
.live-time {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 4%;
|
top: 4%;
|
||||||
left: 16%;
|
left: 15%;
|
||||||
background-color: #444;
|
background-color: #444;
|
||||||
padding: 1.5%;
|
padding: 1.5%;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
font-size: 80%;
|
font-size: 0.75rem;
|
||||||
color: #ddd;
|
color: #ddd;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 10%;
|
width: 10%;
|
||||||
height: 7.5%;
|
height: 7%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.live-state-intermission {
|
.live-state-intermission {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 5%;
|
top: 4%;
|
||||||
left: 4%;
|
left: 4%;
|
||||||
background-color: #444;
|
background-color: #444;
|
||||||
padding: 1.5%;
|
padding: 1.5%;
|
||||||
@@ -204,8 +207,8 @@ h1 {
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
font-weight: bolder;
|
font-weight: bolder;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
width: 13%;
|
width: 11%;
|
||||||
height: 7.5%;
|
height: 8.5%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -213,16 +216,16 @@ h1 {
|
|||||||
|
|
||||||
.live-time-intermission {
|
.live-time-intermission {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 5%;
|
top: 4%;
|
||||||
left: 21.5%;
|
left: 19%;
|
||||||
background-color: #444;
|
background-color: #444;
|
||||||
padding: 1.5%;
|
padding: 1.5%;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
font-size: 80%;
|
font-size: 0.75rem;
|
||||||
color: #ddd;
|
color: #ddd;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
width: 12.5%;
|
width: 10%;
|
||||||
height: 7.5%;
|
height: 8.5%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
Reference in New Issue
Block a user