bundesliga_tippspiel.utils.collections package¶
Submodules¶
bundesliga_tippspiel.utils.collections.Leaderboard module¶
- class bundesliga_tippspiel.utils.collections.Leaderboard.Leaderboard(league: str, season: int, matchday: int, include_bots: bool)¶
Bases:
object
Class that encapsulates a leaderboard
- __init__(league: str, season: int, matchday: int, include_bots: bool)¶
Initializes the leaerboard object :param league: The league of the leaderboard :param season: The season of the leaderboard :param matchday: The matchday of the leaderboard :param include_bots: Whether or not to include bots
- history_to_chart_data() List[Tuple[str, str, List[int]]] ¶
Creates data for the ranking chart :return: The data to be used by the javascript chart
- matchday_ranking_to_table_data() List[Tuple[int, None, None, jerrycan.db.User.User, List[str], List[int], int]] ¶
Calculates the leaderboard ranking to table data for the current matchday only :return: The data as tuple with the following attributes:
position
tendency (None in this case)
tendency-class (None in this case)
user
previous season wins (Empty list in this case)
The matchday wins for the current mtchday only
points on this matchday
- ranking_to_table_data() List[Tuple[int, str, str, jerrycan.db.User.User, List[str], List[int], int]] ¶
Converts the leaderboard into a format that can easily be entered into a HTML table :return: The data as tuple with the following attributes:
position
tendency (example: +2 or -3 etc.)
tendency-class
user
previous season wins
previous matchday wins
points
bundesliga_tippspiel.utils.collections.LeagueTable module¶
- class bundesliga_tippspiel.utils.collections.LeagueTable.LeagueTable(league: str, season: int, matchday: int, user: Optional[jerrycan.db.User.User])¶
Bases:
object
Class that create a league table
- __init__(league: str, season: int, matchday: int, user: Optional[jerrycan.db.User.User])¶
Initializes the lague table object :param league: The league :param season: The season :param matchday: The matchday :param user: Optionally, a user. This will replace the real
results with the bets of the player
- calculate_table() List[Tuple[int, bundesliga_tippspiel.db.match_data.Team.Team, int, int, int, int, int, int, int, int]] ¶
Calculates the table :return: A list of tuples with the following items:
position
team
matches
wins
draws
losses
goals for
goals against
goal difference
points
bundesliga_tippspiel.utils.collections.StatsGenerator module¶
- class bundesliga_tippspiel.utils.collections.StatsGenerator.StatsGenerator(league: str, season: int, matchday: int, include_bots: bool)¶
Bases:
bundesliga_tippspiel.utils.collections.Leaderboard.Leaderboard
Class that generates various statistics. Uses the Leaderboard class as base to calculate the statistics
- __init__(league: str, season: int, matchday: int, include_bots: bool)¶
Initializes the StatsGenerator object. Loads the required data from the database :param league: The league for which to generate stats :param season: The season for which to generate stats :param matchday: The matchday for which to generate stats :param include_bots: Whether or not to include bots
- calculate_average_points_per_team(bets: List[bundesliga_tippspiel.db.user_generated.Bet.Bet]) List[Tuple[bundesliga_tippspiel.db.match_data.Team.Team, float]] ¶
Calculates the average points per team :param bets: The bets to use to calculate the values :return: A ranking of the average points per team
- calculate_point_distribution_per_user() Dict[jerrycan.db.User.User, Dict[int, int]] ¶
Calculates the points distribution for each user :return: {user: {points: count}}
- get_average_points_per_team() List[Tuple[bundesliga_tippspiel.db.match_data.Team.Team, float]] ¶
- Returns
A ranking for the average points achieved by team
- get_correct_bets_ranking() List[Tuple[jerrycan.db.User.User, int]] ¶
- Returns
A ranking for the amount of correct bets for each user
- get_first_half_ranking() List[Tuple[jerrycan.db.User.User, int]] ¶
- Returns
A ranking for the first half of the season
- get_participation_ranking() List[Tuple[jerrycan.db.User.User, int]] ¶
- Returns
A ranking for the participation rate for each user
- get_points_average_ranking() List[Tuple[jerrycan.db.User.User, float]] ¶
- Returns
A ranking for the average points per bet for each user
- get_points_distribution() Dict[int, int] ¶
- Returns
A distribution of points for all possible point results
- get_second_half_ranking() List[Tuple[jerrycan.db.User.User, int]] ¶
- Returns
A ranking for the second half of the season
- get_wrong_bets_ranking() List[Tuple[jerrycan.db.User.User, int]] ¶
- Returns
A ranking for the amount of incorrect bets for each user
bundesliga_tippspiel.utils.collections.UserStatsGenerator module¶
- class bundesliga_tippspiel.utils.collections.UserStatsGenerator.UserStatsGenerator(league: str, season: int, matchday: int, user: jerrycan.db.User.User, include_bots: bool)¶
Bases:
bundesliga_tippspiel.utils.collections.StatsGenerator.StatsGenerator
Class that generates statistics for a single user
- __init__(league: str, season: int, matchday: int, user: jerrycan.db.User.User, include_bots: bool)¶
Initializes the UserStatsGenerator object :param league: The league for which to generate statistics :param season: The season for which to generate statistics :param matchday: The matchday for which to generate statistics :param user: The user for which to generate statistics :param include_bots: Whether or not to include bots
- extract_user_position(ranking: List[Tuple[jerrycan.db.User.User, Any]]) int ¶
Extracts the user’s position from a ranking :return: The position in the ranking
- get_user_average_points_per_team() List[Tuple[bundesliga_tippspiel.db.match_data.Team.Team, float]] ¶
- Returns
The average points per team for this user
- get_user_best_position() int ¶
- Returns
The user’s best position during the season
- get_user_best_team() Tuple[bundesliga_tippspiel.db.match_data.Team.Team, float] ¶
- Returns
The team this user has achieved the most points for so far
- get_user_bet_count() int ¶
- Returns
The amount of bets the user has placed
- get_user_betting_average() float ¶
- Returns
The average points per bet of the user
- get_user_correct_bets() int ¶
- Returns
The amount of correct bets for this user
- get_user_first_half_position() int ¶
- Returns
The user’s position in the first half of the season
- get_user_participation() int ¶
- Returns
The user’s participation up to this point
- get_user_points() int ¶
- Returns
The user’s current point total
- get_user_points_distribution() Dict[int, int] ¶
- Returns
A distribution of points for all possible point results
- get_user_position() int ¶
- Returns
The current position of the user
- get_user_second_half_position() int ¶
- Returns
The user’s position in the second half of the season
- get_user_worst_position() int ¶
- Returns
The user’s worst position during the season
- get_user_worst_team() Tuple[bundesliga_tippspiel.db.match_data.Team.Team, float] ¶
- Returns
The team this user has achieved the least points for so far
- get_user_wrong_bets() int ¶
- Returns
The amount of wrong bets for this user