45 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
9f4a6c966a merge develop into main for v4.0.1 (#35) 2024-02-21 23:43:29 -05:00
4da3c2dfdd fix: live game adjustments 2024-02-21 23:42:41 -05:00
07ff5ac055 feat: Push the games that are in intermission to the bottom, but retain their sort 2024-02-21 18:40:21 -05:00
fe7449537b fix: minor header adjustments 2024-02-21 18:34:26 -05:00
dd8d1ca12b fix: adjust pre and final state 2024-02-21 01:30:00 -05:00
d285314a28 hotfix: define font size for more consistent look 2024-02-21 01:00:03 -05:00
1cd6c7314b Merge develop into main for v4.0.0 (#34) 2024-02-21 00:43:41 -05:00
93b53b86b9 feature: adds hype meter to replace game score (#33) 2024-02-21 00:41:18 -05:00
53f0e69cc5 feature: adds hype meter to replace game score 2024-02-21 00:40:35 -05:00
4b6e8615b1 fix: weigh overtime heavier to compensate for time priority loss 2024-02-20 22:10:07 -05:00
31b4846287 fix: styles.css adjust live games 2024-02-20 22:09:45 -05:00
a329c2e8b2 fix: styles.css adjustments 2024-02-20 14:32:17 -05:00
24de212b98 remove unnecessary comments 2024-02-20 01:35:24 -05:00
6abcd2e448 fix: change spacing between rows 2024-02-20 01:27:19 -05:00
b3a09b27c0 fix: adjust game box spacing 2024-02-20 00:50:35 -05:00
8900bf0d14 fix: adjust sizing to fit space better 2024-02-20 00:47:29 -05:00
3d6afe0df3 fix: adjust styles 2024-02-20 00:41:49 -05:00
d4f5e4c991 fix: make elements more consistent across screen sizes 2024-02-19 21:57:02 -05:00
59fe338658 fix: drop leading zero oin start time 2024-02-19 21:56:06 -05:00
28265af13f fix: resize game boxes and space out (#32) 2024-02-19 19:11:58 -05:00
1fb7673aa4 fix: resize game boxes and space out 2024-02-19 19:10:56 -05:00
4 changed files with 342 additions and 136 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"
@@ -76,9 +88,17 @@ def get_game_outcome(game, game_state):
def calculate_game_priority(game):
# 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
# 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,39 +108,58 @@ 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: 450, 4: 400, 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:
base_priority += 100
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 (-2000 - time_remaining)
return final_priority
def get_team_standings(team_name):
@@ -137,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")
return est_datetime.strftime("%#I:%M %p")

View File

@@ -85,6 +85,32 @@ function updateScoreboard(data) {
finalGamesSection.innerHTML = '';
}
}
updateGauge()
}
function updateGauge() {
document.querySelectorAll('.gauge').forEach(function(gauge) {
// Get the score value from the data-score attribute
var score = parseInt(gauge.getAttribute('data-score'));
// Clamp the score value between 0 and 700
score = Math.min(700, Math.max(0, score));
// Calculate the gauge width as a percentage
var gaugeWidth = (score / 700) * 100;
// Set the width of the gauge
gauge.style.width = gaugeWidth + '%';
if (score <=300) {
gauge.style.backgroundColor = '#4A90E2'
} else if (score <= 550) {
gauge.style.backgroundColor = '#FF4500'
} else {
gauge.style.backgroundColor = '#FF0033'
}
});
}
// Function to generate HTML for game boxes
@@ -140,16 +166,28 @@ 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>';
}
html += '</div>';
html += '<div class="game-info">';
html += '<strong>Game Score: </strong>' + game['Priority'];
html += '</div>';
if (!game['Intermission']) {
html += '<div class="hype-meter-label">';
html += '<strong>Hype Meter</strong>';
html += '</div>';
html += '<div class="game-score-gauge">';
html += '<div class="gauge" data-score="' + game['Priority'] + '"></div>';
html += '</div>';
html += '</div>';
}
html += '</div>';
} else if (state === 'PRE') {
html += '<div class="pre-state">' + game['Start Time'] + '</div>';

View File

@@ -1,14 +1,16 @@
body {
background-color: #121212; /* Dark background color */
font-family: Arial, sans-serif; /* Use a common sans-serif font */
color: #fff; /* White text color */
background-color: #121212;
font-family: Arial, sans-serif;
color: #fff;
margin: 0;
}
h1 {
text-align: center;
margin-top: 15px;
margin-bottom: 25px;
color: #f2f2f2; /* Lighten the text color */
margin-top: 0.8%;
margin-bottom: 1.5%;
color: #f2f2f2;
font-size: 2.2em;
}
.scoreboard {
@@ -19,22 +21,23 @@ h1 {
}
.game-box {
background-color: #333; /* Dark background color for game boxes */
border-radius: 12px; /* Rounded corners */
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Add a subtle shadow */
padding: 20px;
margin-bottom: 20px;
margin-left: 20px;
margin-right: 20px;
width: 300px;
position: relative; /* Position relative for absolute positioning */
background-color: #333;
border-radius: 12px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
padding: 1%;
width: 16%;
max-width: 350px;
position: relative;
margin-left: 1%;
margin-right: 1%;
margin-bottom: 1.15%;
}
.team-info {
display: flex;
align-items: center;
margin-bottom: 7px;
margin-top: 25px; /* Added margin-top */
margin-bottom: 2%;
margin-top: 9%;
}
.team-info-column {
@@ -43,48 +46,66 @@ h1 {
}
.team-logo {
width: 50px;
width: 18%;
height: auto;
margin-right: 10px;
margin-right: 2.25%;
}
.team-name {
font-size: 18px;
font-size: 1rem;
font-weight: bold;
}
/* Add a media query for screens between 769px and 900px */
@media only screen and (max-width: 950px) and (min-width: 769px) {
.team-name {
font-size: 0.55rem; /* Adjusted font size for screens between 769px and 900px */
}
}
.team-score {
font-size: 25px;
font-size: 1.35rem;
font-weight: bold;
margin-left: auto;
}
.team-record {
font-size: 12px;
margin-left: auto;
font-size: 0.8rem;
font-weight: bold;
margin-left: auto;
}
/* Add a media query for screens between 769px and 900px */
@media only screen and (max-width: 950px) and (min-width: 769px) {
.team-record {
font-size: 0.45rem; /* Adjusted font size for screens between 769px and 900px */
}
}
.team-sog {
font-size: 12px; /* Adjust font size as needed */
color: #ddd; /* Lighter text color */
font-size: 0.75rem;
color: #ddd;
}
.team-power-play {
font-size: 12px; /* Adjust font size as needed */
color: red; /* Set color to red */
margin-left: 10px; /* Add some margin for spacing */
font-size: 12px;
color: red;
margin-left: 10px;
}
.game-info {
margin-top: 12px;
color: #aaa; /* Lighten the text color */
color: #aaa;
text-align: center;
font-size: 14px;
font-size: 80%;
}
.game-info strong {
margin-right: 5px;
.hype-meter-label {
margin-top: 3%;
color: #aaa;
text-align: center;
font-size: 80%;
margin-bottom: 3%;
}
.live-dot {
@@ -99,88 +120,115 @@ h1 {
.pre-state {
position: absolute;
top: 10px;
left: 10px; /* Adjusted left position */
background-color: #444; /* Darker background color for pre state */
padding: 5px;
top: 5%;
left: 3%;
background-color: #444;
padding: 1.5%;
border-radius: 5px;
font-size: 12px;
color: #fff; /* White text color for live state */
font-weight: bolder; /* Bold text for live state */
z-index: 1; /* Ensure the live state box is above other content */
font-size: 0.75rem;
color: #fff;
font-weight: bolder;
z-index: 1;
width: auto;
height: 7%;
display: flex;
justify-content: space-evenly;
align-items: center;
}
/* Add a media query for screens between 769px and 900px */
@media only screen and (max-width: 950px) and (min-width: 769px) {
.pre-state {
font-size: 0.55rem; /* Adjusted font size for screens between 769px and 900px */
}
}
.final-state {
position: absolute;
top: 10px;
left: 10px; /* Adjusted left position */
background-color: #444; /* Darker background color for final state */
padding: 5px;
top: 5%;
left: 3%;
background-color: #444;
padding: 1.5%;
border-radius: 5px;
font-size: 12px;
color: #ddd; /* Lighter text color for final state */
z-index: 1; /* Ensure the final state box is above other content */
font-size: 0.7rem;
color: #ddd;
z-index: 1;
font-weight: bold;
width: auto;
height: 7%;
display: flex;
justify-content: space-evenly;
align-items: center;
}
.live-state {
position: absolute;
top: 10px;
left: 10px; /* Adjusted left position */
background-color: #0b6e31; /* Darker green background color for live state */
padding: 5px;
top: 4%;
left: 4%;
background-color: #0b6e31;
padding: 1.5%;
border-radius: 5px;
font-size: 12px;
color: #fff; /* White text color for live state */
font-weight: bolder; /* Bold text for live state */
z-index: 1; /* Ensure the live state box is above other content */
width: 18px;
}
.live-state-intermission {
position: absolute;
top: 10px;
left: 10px; /* Adjusted left position */
background-color: #444; /* Darker green background color for live state */
padding: 5px;
border-radius: 5px;
font-size: 12px;
color: #fff; /* White text color for live state */
font-weight: bolder; /* Bold text for live state */
z-index: 1; /* Ensure the live state box is above other content */
width: 40px;
font-size: 0.72rem;
color: #fff;
font-weight: bolder;
z-index: 1;
width: 7%;
height: 7%;
display: flex;
justify-content: space-evenly;
align-items: center;
}
.live-time {
position: absolute;
top: 10px;
left: 45px; /* Adjusted left position */
background-color: #444; /* Darker background color for time box */
padding: 5px;
top: 4%;
left: 15%;
background-color: #444;
padding: 1.5%;
border-radius: 5px;
font-size: 12px;
color: #ddd; /* Lighter text color for time box */
z-index: 1; /* Ensure the time box is above other content */
width: 30px;
display: flex; /* Use flexbox */
justify-content: space-evenly; /* Center content horizontally */
align-items: center; /* Center content vertically */
font-size: 0.75rem;
color: #ddd;
z-index: 1;
display: flex;
justify-content: space-evenly;
align-items: center;
width: 10%;
height: 7%;
}
.live-state-intermission {
position: absolute;
top: 4%;
left: 4%;
background-color: #444;
padding: 1.5%;
border-radius: 5px;
font-size: 80%;
color: #fff;
font-weight: bolder;
z-index: 1;
width: 11%;
height: 8.5%;
display: flex;
justify-content: space-evenly;
align-items: center;
}
.live-time-intermission {
position: absolute;
top: 10px;
left: 65px; /* Adjusted left position */
background-color: #444; /* Darker background color for time box */
padding: 5px;
top: 4%;
left: 19%;
background-color: #444;
padding: 1.5%;
border-radius: 5px;
font-size: 12px;
color: #ddd; /* Lighter text color for time box */
z-index: 1; /* Ensure the time box is above other content */
width: 30px;
display: flex; /* Use flexbox */
justify-content: space-evenly; /* Center content horizontally */
align-items: center; /* Center content vertically */
font-size: 0.75rem;
color: #ddd;
z-index: 1;
width: 10%;
height: 8.5%;
display: flex;
justify-content: space-evenly;
align-items: center;
}
#live-games-section {
@@ -204,7 +252,19 @@ h1 {
justify-content: flex-start;
}
/* Existing CSS styles */
/* Add styles for the game score gauge */
.game-score-gauge {
height: 1%;
background-color: #ccc;
border-radius: 5px;
overflow: hidden;
}
.gauge {
height: 10px; /* Adjust height as needed */
/*#8A2BE2*/
/*#6699CC*/
}
/* Add media query for smaller screens */
@media only screen and (max-width: 768px) {
@@ -214,39 +274,108 @@ h1 {
}
.game-box {
width: 90%; /* Adjust width for better fit on smaller screens */
margin: 10px; /* Adjust margins */
width: 90%;
padding: 4%;
margin-bottom: 4%;
margin-left: 2%;
margin-right: 2%;
max-width: 1000px;
}
.team-info {
align-items: center; /* Center align items */
margin-top: 26px; /* Adjust top margin */
margin-bottom: 5px; /* Adjust bottom margin */
align-items: center;
margin-top: 10%;
margin-bottom: 2%;
}
.team-logo {
width: 36px; /* Adjust logo size */
height: 36px;
width: 12%;
height: auto;
}
.team-name {
font-size: 16px; /* Decrease font size for better readability */
font-size: 100%;
font-weight: bold;
}
.team-score {
font-size: 24px; /* Decrease font size for better readability */
font-size: 140%;
font-weight: bold;
}
.game-info {
font-size: 12px; /* Decrease font size for better readability */
.team-sog {
font-size: 70%;
}
.live-state,
.live-time,
.pre-state,
.final-state {
font-size: 12px; /* Decrease font size for better readability */
.game-info {
font-size: 90%;
}
.live-state {
top: 5%;
left: 3.5%;
padding: 1.5%;
border-radius: 5px;
font-size: 80%;
width: 5.5%;
height: 7.2%;
}
.live-time {
top: 5%;
left: 13%;
padding: 1.5%;
border-radius: 5px;
font-size: 80%;
display: flex;
justify-content: space-evenly;
align-items: center;
width: 7%;
height: 7.2%;
}
.live-state-intermission {
top: 5%;
left: 3.5%;
padding: 1.5%;
border-radius: 5px;
font-size: 80%;
width: 11%;
height: 7.5%;
display: flex;
justify-content: space-evenly;
align-items: center;
}
.live-time-intermission {
top: 5%;
left: 18.5%;
padding: 1.5%;
border-radius: 5px;
font-size: 80%;
width: 8%;
height: 7.5%;
display: flex;
justify-content: space-evenly;
align-items: center;
}
.final-state {
top: 5%;
left: 3.5%;
padding: 1.5%;
border-radius: 5px;
font-size: 72%;
width: auto;
height: 7.5%;
}
.pre-state {
top: 5%;
left: 3.5%;
padding: 1.5%;
border-radius: 5px;
font-size: 80%;
}
}