Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
pre-playoff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
User Name committed Apr 18, 2024
1 parent 9cebc44 commit bc315ac
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
14 changes: 11 additions & 3 deletions src/boards/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
import debug
from boards.scoreticker import Scoreticker
from boards.seriesticker import Seriesticker
# from boards.seriesticker import Seriesticker
from boards.standings import Standings
from boards.team_summary import TeamSummary
from boards.clock import Clock
Expand Down Expand Up @@ -222,17 +222,25 @@ def fallback(self, data, matrix, sleepEvent):
def scoreticker(self, data, matrix, sleepEvent):
Scoreticker(data, matrix, sleepEvent).render()

# Since 2024, the playoff features are removed as we have not colected the new API endpoint for them.
def seriesticker(self, data, matrix, sleepEvent):
debug.info("seriesticker is disabled. This feature is not available right now")
pass
'''
forcing it to show since the playoff start and regular season end are in conflict for 2021
'''
Seriesticker(data, matrix, sleepEvent).render()

#Seriesticker(data, matrix, sleepEvent).render()

'''if data.status.is_playoff(data.today, data.playoffs):
Seriesticker(data, matrix, sleepEvent).render()
'''

# Since 2024, the playoff features are removed as we have not colected the new API endpoint for them.
def stanley_cup_champions(self, data, matrix, sleepEvent):
StanleyCupChampions(data, matrix, sleepEvent).render()
debug.info("stanley_cup_champions is disabled. This feature is not available right now")
pass
#StanleyCupChampions(data, matrix, sleepEvent).render()

def standings(self, data, matrix, sleepEvent):
#Try making standings a thread
Expand Down
23 changes: 16 additions & 7 deletions src/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def __init__(self, config):
self.network_issues = False

# Get the teams info
print("update Teams info")
self.teams_info = self.get_teams()
# So oddly enough, there are a handful of situations where the API does not include the team_id
# it's happening often enough that it's worth keeping a second teams_info that is keyed off of the
Expand All @@ -163,6 +164,7 @@ def __init__(self, config):
self.new_data = True

# Get the status from the API
print("Get status from api")
self.get_status()

# Get favorite team's id
Expand All @@ -175,6 +177,7 @@ def __init__(self, config):
#self.current_game_index = 0

# Fetch the games for today
print("refresh games")
self.refresh_games()

# Flag to indicate if all preferred games are Final
Expand All @@ -184,6 +187,7 @@ def __init__(self, config):
self.today = self.date()

# Get refresh standings
print("refresh standings")
self.refresh_standings()

# Playoff Flag
Expand Down Expand Up @@ -295,26 +299,30 @@ def refresh_games(self):
self.games = []
self.pref_games = []
return data

self.games = data["games"]
self.pref_games = filter_list_of_games(self.games, self.pref_teams)

# Populate the TeamInfo classes used for the team_summary board
for team_id in self.pref_teams:
# import pdb; pdb.set_trace()
team_info = self.teams_info[team_id].details
pg, ng = nhl_api.info.team_previous_game(team_info.abbrev, str(date.today()))
team_info.previous_game = pg
team_info.next_game = ng

try:
pg, ng = nhl_api.info.team_previous_game(team_info.abbrev, str(date.today()))
team_info.previous_game = pg
team_info.next_game = ng
except:
pass
print("probe 2")
if self.config.preferred_teams_only and self.pref_teams:
self.games = self.pref_games

print("probe 3")
if not self.is_pref_team_offday() and self.config.live_mode:
#self.pref_games = prioritize_pref_games(self.pref_games, self.pref_teams)
self.check_all_pref_games_final()
# TODO: This shouldn't be needed to get the fact that your preferred team has a game today
self.check_game_priority()

print("probe 4")
self.network_issues = False
break

Expand All @@ -326,6 +334,7 @@ def refresh_games(self):
sleep(NETWORK_RETRY_SLEEP_TIME)

except IndexError as error_message:
print("probe 5")
debug.error(error_message)
debug.info("All preferred games are Final, showing the top preferred game")
#self.current_game_index = 0
Expand Down
1 change: 1 addition & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def run():

# This data will get passed throughout the entirety of this program.
# It initializes all sorts of things like current season, teams, helper functions
print("init Data")
data = Data(config)

#If we pass the logging arguments on command line, override what's in the config.json, else use what's in config.json (color will always be false in config.json)
Expand Down
10 changes: 5 additions & 5 deletions src/renderer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from boards.boards import Boards
from boards.clock import Clock
from boards.stanley_cup_champions import StanleyCupChampions
from boards.seriesticker import Seriesticker
#from boards.seriesticker import Seriesticker
from boards.team_summary import TeamSummary
from boards.standings import Standings
from data.scoreboard import Scoreboard
Expand Down Expand Up @@ -169,10 +169,10 @@ def __render_game_day(self):
debug.info("Game Over")
sbrenderer = ScoreboardRenderer(self.data, self.matrix, self.scoreboard)
self.check_new_goals()
if self.data.isPlayoff and self.data.stanleycup_round:
""" if self.data.isPlayoff and self.data.stanleycup_round:
self.data.check_stanley_cup_champion()
if self.data.cup_winner_id:
StanleyCupChampions(self.data, self.matrix, self.sleepEvent).render()
StanleyCupChampions(self.data, self.matrix, self.sleepEvent).render() """

self.__render_postgame(sbrenderer)
self.sleepEvent.wait(self.refresh_rate)
Expand All @@ -184,10 +184,10 @@ def __render_game_day(self):
debug.info("FINAL")
sbrenderer = ScoreboardRenderer(self.data, self.matrix, self.scoreboard)
self.check_new_goals()
if self.data.isPlayoff and self.data.stanleycup_round:
""" if self.data.isPlayoff and self.data.stanleycup_round:
self.data.check_stanley_cup_champion()
if self.data.cup_winner_id:
StanleyCupChampions(self.data, self.matrix, self.sleepEvent).render()
StanleyCupChampions(self.data, self.matrix, self.sleepEvent).render() """
self.__render_postgame(sbrenderer)

self.sleepEvent.wait(self.refresh_rate)
Expand Down

0 comments on commit bc315ac

Please sign in to comment.