bundesliga_tippspiel.background package¶
Submodules¶
bundesliga_tippspiel.background.openligadb module¶
- class bundesliga_tippspiel.background.openligadb.UpdateTracker¶
Bases:
object
Class that keeps track of OpenLigaDB updates, which is useful to avoid rate limiting
- UPDATES: Dict[Tuple[str, int], int] = {}¶
- static update_required(league: str, season: int) bool ¶
Checks if a league requires updating :param league: The league to check :param season: The season to check :return: True if update required, False otherwise
- bundesliga_tippspiel.background.openligadb.parse_goal(goal_data: Dict[str, Any], match: bundesliga_tippspiel.db.match_data.Match.Match) Optional[bundesliga_tippspiel.db.match_data.Goal.Goal] ¶
Parses a goal JSON object and generates a Goal object :param match: The match in which the goal was scored :param goal_data: The goal data to parse :return: The generated Goal object
- bundesliga_tippspiel.background.openligadb.parse_match(match_data: Dict[str, Any], league: str, season: int) bundesliga_tippspiel.db.match_data.Match.Match ¶
Parses a Match object from JSON match data :param match_data: The match data to parse :param league: The league :param season: The season :return: The generated Match object
- bundesliga_tippspiel.background.openligadb.parse_player(goal_data: Dict[str, Any], team_abbreviation: str) bundesliga_tippspiel.db.match_data.Player.Player ¶
Parses a Player object from a Goal JSON data object :param goal_data: The data of a goal the player scored :param team_abbreviation: The Team of the player :return: The generated Player object
- bundesliga_tippspiel.background.openligadb.parse_team(team_data: Dict[str, Any]) bundesliga_tippspiel.db.match_data.Team.Team ¶
Parses team-related JSON data and generates a Team object from that :param team_data: The team data to parse :return: The generated Team object
- bundesliga_tippspiel.background.openligadb.update_match_data(league: Optional[str] = None, season: Optional[str] = None)¶
Updates the database with the match data for the specified league and season using openligadb data :param league: The league for which to update the data :param season: The season for which to update the data :return: None
- bundesliga_tippspiel.background.openligadb.update_openligadb()¶
Updates all OpenLigaDB leagues in the configuration :return: None
bundesliga_tippspiel.background.pointscalc module¶
- bundesliga_tippspiel.background.pointscalc.calculate_matchday_points(users: List[jerrycan.db.User.User], seasons: Dict[Tuple[str, int], Dict[int, List[bundesliga_tippspiel.db.match_data.Match.Match]]]) Dict[Tuple[str, int], Dict[int, Dict[jerrycan.db.User.User, int]]] ¶
Calculates every user’s points per matchday for each season :param users: The users to include :param seasons: The seasons data :return: {(league, season): {matchday: {user: points}}}
- bundesliga_tippspiel.background.pointscalc.create_categorized_matches() Dict[Tuple[str, int], Dict[int, List[bundesliga_tippspiel.db.match_data.Match.Match]]] ¶
Sorts matches into seasons and matchdays :return: The matches categorized like this:
{(league, season): {matchday: [match, …]}}
- bundesliga_tippspiel.background.pointscalc.process_league_table(league: str, season: int, matchday: int, user_points: Dict[jerrycan.db.User.User, int], previous_positions: Dict[jerrycan.db.User.User, int], previous_no_bot_positions: Dict[jerrycan.db.User.User, int])¶
Processes the league table entries and updates their corresponding database entries. :param league: The league to process :param season: The season to process :param matchday: The matchday to process :param user_points: The points for every user to process: :param previous_positions: Dictionary that keeps track of the previous
positions of the users
- Parameters
previous_no_bot_positions – Dictionary that keeps track of the previous positions of the users disregarding bots
- Returns
None
- bundesliga_tippspiel.background.pointscalc.process_matchday_winners(per_matchday_data: Dict[Tuple[str, int], Dict[int, Dict[jerrycan.db.User.User, int]]])¶
Processes the matchday winners :param per_matchday_data: The points of each user per matchday :return: None
- bundesliga_tippspiel.background.pointscalc.update_bet_points()¶
Updates the bet points :return: None
- bundesliga_tippspiel.background.pointscalc.update_leaderboard()¶
Updates the leaderboard entries :return: None
bundesliga_tippspiel.background.reminders module¶
- bundesliga_tippspiel.background.reminders.send_due_reminders()¶
Sends all email reminders that are due :return: None
bundesliga_tippspiel.background.season_events module¶
- bundesliga_tippspiel.background.season_events.handle_midseason_reminder() bool ¶
Handles sending out midseason reminders :return: Whether the reminder was sent or not
- bundesliga_tippspiel.background.season_events.handle_postseason_wrapup() bool ¶
Handles the post-season wrapup :return: None
- bundesliga_tippspiel.background.season_events.handle_preseason_reminder() bool ¶
Sends a reminder to existing users a week before the start of the season :return: Whether or not the reminder was sent
- bundesliga_tippspiel.background.season_events.handle_season_events()¶
Handles any events that happen once every season :return: None
- bundesliga_tippspiel.background.season_events.load_season_events() List[bundesliga_tippspiel.db.SeasonEvent.SeasonEvent] ¶
Loads all event states from the database :return: The event states
Module contents¶
- bundesliga_tippspiel.background.bg_tasks: Dict[str, Tuple[int, Callable]] = {'handle_season_events': (86400, <function handle_season_events>), 'send_due_reminders': (60, <function send_due_reminders>), 'update_db_data': (30, <function update_openligadb>), 'update_leaderboard': (30, <function update_leaderboard>)}¶
A dictionary containing background tasks for the flask application