leaguemanager.services.scheduling.round_robin¶
Module Contents¶
Classes¶
Service for generating and managing round-robin schedules. |
Data¶
API¶
- leaguemanager.services.scheduling.round_robin.__all__¶
[‘RoundRobinSchedule’]
- class leaguemanager.services.scheduling.round_robin.RoundRobinSchedule¶
Service for generating and managing round-robin schedules.
- league_manager_registry: leaguemanager.dependency.LeagueManager | None¶
‘field(…)’
- _season: leaguemanager.models.Season¶
‘field(…)’
- generate_schedule(shuffle_order: bool = True, phase_identifier: str = 'Matchday') None¶
Generate the round-robin schedule.
- abstract get_schedule() None¶
Get the generated round-robin schedule.
- abstract update_schedule() None¶
Update the existing round-robin schedule.
- get_or_create_phases(phase_identifier: str = 'Matchday') None¶
Creates phases if they do not exist in the database.
- save_matchups_to_db(matchups: Iterable[leaguemanager.schema.Matchup]) list[leaguemanager.models.Fixture]¶
Save matchups to the database as Fixtures and TeamStats.
- property registry: leaguemanager.dependency.LeagueManager¶
Get the LeagueManager registry.
- property season_service: leaguemanager.services.SeasonService¶
Get the SeasonService from the LeagueManager registry.
- property ruleset_service: leaguemanager.services.RulesetService¶
Get the RulesetService from the LeagueManager registry.
- property phase_service: leaguemanager.services.PhaseService¶
Get the PhaseService from the LeagueManager registry.
- property fixture_service: leaguemanager.services.FixtureService¶
Get the FixtureService from the LeagueManager registry.
- property team_stats_service: leaguemanager.services.TeamStatsService¶
Get the TeamStatsService from the LeagueManager registry.
- property team_service: leaguemanager.services.TeamService¶
Get the TeamService from the LeagueManager registry.
- property season: leaguemanager.models.Season¶
Get the current season.
- property ruleset: leaguemanager.models.Ruleset¶
Get the current ruleset.
- property teams: list[leaguemanager.models.Team]¶
Get the teams participating in the current season.
- create_season_matchups(shuffle_order: bool = True, phases: list[leaguemanager.models.Phase] = None) list[leaguemanager.schema.Matchup]¶
Generate matchups for the entire season.
- phase_matchups(phase: leaguemanager.models.Phase, count: int, round_number: int) list[leaguemanager.schema.Matchup]¶
Create events/matchups for a specific phase.
See: https://en.wikipedia.org/wiki/Round-robin_tournament#Circle_method for details on round-robin scheduling. Splitting teams creates “bye week” team to ensure even matchups, and the phase number is used to rotate the teams for each phase of the round-robin schedule.
- create_matchups(matchups: Iterable[tuple[leaguemanager.models.Team, leaguemanager.models.Team]], phase: leaguemanager.models.Phase, count: int, round_number: int) Generator[leaguemanager.schema.Matchup, None, None]¶
Create Matchup objects from the list of team matchups.
- split_teams(team_obj: Iterable[leaguemanager.models.Team]) tuple[list[leaguemanager.models.Team], list[leaguemanager.models.Team]]¶
Split a list of teams in half, creating “bye week” team if number of teams is odd.
- generate_venue_number(match_number: int) int¶
Generates a venue number based on match_number and venue count set in the Ruleset.
If there is only one venue, it always returns 1. If there are 3 venues and the match number is 1, it returns 1. If the match number is 2, it returns 2. If the match number is 3, it returns 3. If the match number is 4, it wraps around and returns 1.
- generate_game_time(match_number: int, phase: int) leaguemanager.schema.GameTime¶
Generates a GameTime object based on when the match should be played.
The date can be derived by incrementing the start date of the season by the product of the phase and number of days to increment between phases (i.e., 7 days for weekly matches). The match start time is determined by how many matches can be played concurrently (venue_count), the match number for that phase, as well as the game length and time between matches set in the Ruleset.
- _list_of_days() list[str]¶
Return a list of days when fixtures can be scheduled based on the ruleset.
- _increment_days() list[int]¶
Return a list of days to increment based on the ruleset.
- _increment_time(match_count: int, match_date: datetime.datetime) leaguemanager.schema.GameTime¶
Return the time increment between matches based on the ruleset.
- _convert_to_hours_and_minutes(td: datetime.timedelta, multiplier: int) tuple[int, int]¶
Convert a timedelta to (hours, minutes).