3 Commits

Author SHA1 Message Date
975ac4d4ec fix: fixes checks for non live games (#24) 2024-02-19 03:50:07 -05:00
8611471360 fix: fixes checks for non live games 2024-02-19 03:49:02 -05:00
18802f6ef5 hotfix: update dockerfile 2024-02-19 02:32:20 -05:00
6 changed files with 59 additions and 22 deletions

View File

@@ -6,14 +6,17 @@ ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1 ENV PYTHONUNBUFFERED 1
# Set the working directory in the container # Set the working directory in the container
WORKDIR / WORKDIR /app
# Copy the current directory contents into the container at /app # Copy the current directory contents into the container at /app
COPY . / COPY . /app
# Install any needed dependencies specified in requirements.txt # Install any needed dependencies specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
# Create the directory for scoreboard data
RUN mkdir -p app/data
# Expose the Flask port # Expose the Flask port
EXPOSE 2897 EXPOSE 2897

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=0, second=0, microsecond=0) # 7:00 PM EST 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=0, second=0, microsecond=0) # 3:00 AM EST end_time_evening = now.replace(hour=8, 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

@@ -10,16 +10,16 @@ def extract_game_info(scoreboard_data):
game_state = convert_game_state(game["gameState"]) game_state = convert_game_state(game["gameState"])
extracted_info.append({ extracted_info.append({
"Home Team": game["homeTeam"]["name"]["default"], "Home Team": game["homeTeam"]["name"]["default"],
"Home Score": game["homeTeam"]["score"], "Home Score": game["homeTeam"]["score"] if game_state != "PRE" else "N/A",
"Away Team": game["awayTeam"]["name"]["default"], "Away Team": game["awayTeam"]["name"]["default"],
"Away Score": game["awayTeam"]["score"], "Away Score": game["awayTeam"]["score"] if game_state != "PRE" else "N/A",
"Home Logo": game["homeTeam"]["logo"], "Home Logo": game["homeTeam"]["logo"],
"Away Logo": game["awayTeam"]["logo"], "Away Logo": game["awayTeam"]["logo"],
"Game State": game_state, "Game State": game_state,
"Period": process_period(game), "Period": process_period(game),
"Time Remaining": process_time_remaining(game), "Time Remaining": process_time_remaining(game),
"Time Running": game["clock"]["running"], "Time Running": game["clock"]["running"] if game_state == "LIVE" else "N/A",
"Intermission": game["clock"]["inIntermission"], "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": game["homeTeam"]["record"] if game["gameState"] in ["PRE", "FUT"] else "N/A",

View File

@@ -16,31 +16,73 @@ function fetchScoreboardData() {
// Function to update scoreboard with fetched data // Function to update scoreboard with fetched data
function updateScoreboard(data) { function updateScoreboard(data) {
var liveGamesSection = document.getElementById("live-games-section"); var liveGamesSection = document.getElementById('live-games-section');
var preGamesSection = document.getElementById('pre-games-section'); var preGamesSection = document.getElementById('pre-games-section');
var finalGamesSection = document.getElementById('final-games-section'); var finalGamesSection = document.getElementById('final-games-section');
if (liveGamesSection) { if (liveGamesSection) {
var liveGamesExist = data && data.live_games && data.live_games.length > 0; var liveGamesExist = data && data.live_games && data.live_games.length > 0;
if (liveGamesExist) { if (liveGamesExist) {
document.getElementById('live-games').innerText = "Live Games" if (!document.getElementById('live-games')) {
var targetElement = document.getElementById('live-games-section');
var newElement = document.createElement('h1');
newElement.setAttribute('id', 'live-games');
newElement.innerText = 'Live Games';
targetElement.parentNode.insertBefore(newElement, targetElement);
}
liveGamesSection.innerHTML = generateGameBoxes(data.live_games, 'LIVE'); liveGamesSection.innerHTML = generateGameBoxes(data.live_games, 'LIVE');
} else {
var liveGamesElement = document.getElementById('live-games');
if (liveGamesElement) {
liveGamesElement.remove();
}
liveGamesSection.innerHTML = '';
} }
} }
if (preGamesSection) { if (preGamesSection) {
var preGamesExist = data && data.pre_games && data.pre_games.length > 0; var preGamesExist = data && data.pre_games && data.pre_games.length > 0;
if (preGamesExist) { if (preGamesExist) {
document.getElementById('on-later').innerText = "On Later" if (!document.getElementById('on-later')) {
var targetElement = document.getElementById('pre-games-section');
var newElement = document.createElement('h1');
newElement.setAttribute('id', 'on-later');
newElement.innerText = 'Scheduled Games';
targetElement.parentNode.insertBefore(newElement, targetElement);
}
preGamesSection.innerHTML = generateGameBoxes(data.pre_games, 'PRE'); preGamesSection.innerHTML = generateGameBoxes(data.pre_games, 'PRE');
} else {
var onLaterElement = document.getElementById('on-later');
if (onLaterElement) {
onLaterElement.remove();
}
preGamesSection.innerHTML = '';
} }
} }
if (finalGamesSection) { if (finalGamesSection) {
var finalGamesExist = data && data.final_games && data.final_games.length > 0; var finalGamesExist = data && data.final_games && data.final_games.length > 0;
// Check if final games exist
if (finalGamesExist) { if (finalGamesExist) {
document.getElementById('game-over').innerText = "Game Over" // Create or update "Game Over" heading
if (!document.getElementById('game-over')) {
var targetElement = document.getElementById('final-games-section');
var newElement = document.createElement('h1');
newElement.setAttribute('id', 'game-over');
newElement.innerText = 'Game Over';
targetElement.parentNode.insertBefore(newElement, targetElement);
}
// Update final games section with generated game boxes
finalGamesSection.innerHTML = generateGameBoxes(data.final_games, 'FINAL'); finalGamesSection.innerHTML = generateGameBoxes(data.final_games, 'FINAL');
} else {
// Remove "Game Over" heading if it exists and clear final games section
var gameOverElement = document.getElementById('game-over');
if (gameOverElement) {
gameOverElement.remove();
}
finalGamesSection.innerHTML = '';
} }
} }
} }

View File

@@ -6,7 +6,8 @@ body {
h1 { h1 {
text-align: center; text-align: center;
margin-top: 20px; margin-top: 15px;
margin-bottom: 25px;
color: #f2f2f2; /* Lighten the text color */ color: #f2f2f2; /* Lighten the text color */
} }
@@ -177,7 +178,6 @@ h1 {
align-items: start; align-items: start;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: flex-start; justify-content: flex-start;
margin-top: 20px;
} }
#pre-games-section { #pre-games-section {
@@ -185,7 +185,6 @@ h1 {
align-items: start; align-items: start;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: flex-start; justify-content: flex-start;
margin-top: 20px;
} }
#final-games-section { #final-games-section {
@@ -193,7 +192,6 @@ h1 {
align-items: start; align-items: start;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: flex-start; justify-content: flex-start;
margin-top: 20px;
} }
/* Existing CSS styles */ /* Existing CSS styles */

View File

@@ -6,15 +6,9 @@
<link rel="stylesheet" type="text/css" href="static\styles.css"> <link rel="stylesheet" type="text/css" href="static\styles.css">
</head> </head>
<body> <body>
<h1 id="live-games"></h1>
<div id="live-games-section"></div> <div id="live-games-section"></div>
<h1 id="on-later"></h1>
<div id="pre-games-section"></div> <div id="pre-games-section"></div>
<h1 id="game-over"></h1>
<div id="final-games-section"></div> <div id="final-games-section"></div>
<script src="/static/script.js"></script> <script src="/static/script.js"></script>
</body> </body>
</html> </html>