9 Commits

Author SHA1 Message Date
18802f6ef5 hotfix: update dockerfile 2024-02-19 02:32:20 -05:00
4304954bc3 hotfix: change dockerfile 2024-02-19 02:27:31 -05:00
90cccf581a Merge develop into main for v3.0.2 (#23) 2024-02-19 02:14:18 -05:00
a3ee38d774 fix: last period type (#22) 2024-02-19 02:07:40 -05:00
5beb7e2b44 fix: last period type 2024-02-19 02:07:08 -05:00
c926821e1a .gitignore: update gitignore 2024-02-19 01:31:39 -05:00
a21bb3cdcc Merge pull request #20 from JoshNotWright/fix/create-data-folder
fix: creates data folder
2024-02-19 01:30:03 -05:00
148bdaefc4 fix: creates data folder 2024-02-19 01:29:34 -05:00
e645cb2b08 Update README.md 2024-02-19 01:20:56 -05:00
7 changed files with 14 additions and 10 deletions

4
.gitignore vendored
View File

@@ -1,7 +1,7 @@
/nhle_scoreboard_response.txt /nhle_scoreboard_response.txt
/nhle_standings_response.txt /nhle_standings_response.txt
/nhl_standings.db /app/data/nhl_standings.db
/scoreboard_data.json /app/data/scoreboard_data.json
/__pycache__ /__pycache__
/app/__pycache__ /app/__pycache__
/app/scoreboard/__pycache__ /app/scoreboard/__pycache__

View File

@@ -14,6 +14,9 @@ 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

@@ -32,7 +32,7 @@ This web application displays live NHL game scores, team statistics, and game st
3. Run the application: 3. Run the application:
```bash ```bash
python app.py python run.py
``` ```
4. Open your web browser and navigate to `http://localhost:2897` to view the scoreboard. 4. Open your web browser and navigate to `http://localhost:2897` to view the scoreboard.

View File

@@ -3,7 +3,7 @@ from flask import render_template, jsonify
from app.scoreboard.process_data import extract_game_info from app.scoreboard.process_data import extract_game_info
import json import json
SCOREBOARD_DATA_FILE = 'scoreboard_data.json' SCOREBOARD_DATA_FILE = 'app/data/scoreboard_data.json'
@app.route('/') @app.route('/')
def index(): def index():

View File

@@ -2,7 +2,7 @@ import requests
from datetime import datetime from datetime import datetime
import json import json
SCOREBOARD_DATA_FILE = 'scoreboard_data.json' SCOREBOARD_DATA_FILE = 'app/data/scoreboard_data.json'
def get_scoreboard_data(): def get_scoreboard_data():
now = datetime.now() now = datetime.now()

View File

@@ -7,6 +7,7 @@ def extract_game_info(scoreboard_data):
extracted_info = [] extracted_info = []
for game in scoreboard_data.get("games", []): for game in scoreboard_data.get("games", []):
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"],
@@ -14,7 +15,7 @@ def extract_game_info(scoreboard_data):
"Away Score": game["awayTeam"]["score"], "Away Score": game["awayTeam"]["score"],
"Home Logo": game["homeTeam"]["logo"], "Home Logo": game["homeTeam"]["logo"],
"Away Logo": game["awayTeam"]["logo"], "Away Logo": game["awayTeam"]["logo"],
"Game State": convert_game_state(game["gameState"]), "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"],
@@ -27,7 +28,7 @@ def extract_game_info(scoreboard_data):
"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"]),
"Away Power Play": get_power_play_info(game, game["awayTeam"]["name"]["default"]), "Away Power Play": get_power_play_info(game, game["awayTeam"]["name"]["default"]),
"Last Period Type": get_game_outcome(game) "Last Period Type": get_game_outcome(game, game_state)
}) })
# Sort games based on priority # Sort games based on priority
@@ -70,8 +71,8 @@ def get_power_play_info(game, team_name):
return f"PP {game['situation']['timeRemaining']}" return f"PP {game['situation']['timeRemaining']}"
return "" return ""
def get_game_outcome(game): def get_game_outcome(game, game_state):
return game["gameOutcome"]["lastPeriodType"] if game["gameState"] == "FINAL" else "N/A" return game["gameOutcome"]["lastPeriodType"] if game_state == "FINAL" else "N/A"
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

View File

@@ -46,7 +46,7 @@ def extract_standings_info():
def update_nhl_standings(): def update_nhl_standings():
# Connect to SQLite database # Connect to SQLite database
conn = sqlite3.connect("nhl_standings.db") conn = sqlite3.connect("app/data/nhl_standings.db")
# Create standings table if it doesn't exist # Create standings table if it doesn't exist
create_standings_table(conn) create_standings_table(conn)