supercontest.dbsession.selects
Actual reads to the cache/db.
Example for raw SQL via ORM:
season_id = db.session.scalar(text("SELECT last_value FROM seasons_id_seq"))
Functions
Gives list of users with the 'Admin' role. |
|
Simply gives the full list of user objects. |
|
Gets a list of all contestant objects available to the app. |
|
Gets a list of all contestant objects in a given week. |
|
Gets a list of all game objects available to the app. |
|
Gets a list of all game objects in a given season. |
|
Gets a list of all game objects in a given week. |
|
Get leagues associated with a season. |
|
Gets a list of all location objects available to the app. |
|
Returns the official paid league for a specific season. |
|
Gets a list of all pick objects available to the app. |
|
Gets a list of all pick objects in a given season. |
|
Gets a list of all pick objects in a given week. |
|
Gets a list of all prediction objects available to the app. |
|
Returns the id for a Role row, given its name. |
|
Returns the season object for a given datetime. |
|
Numerically sorted season objects, ascending. |
|
Numerically sorted week objects for a season, ascending. |
|
Gets a list of all game status objects available to the app. |
|
Returns the team object, given its name. |
|
Gets a list of all team objects available to the app. |
|
Takes an email, returns a user object. |
|
Returns a list of users in a given league. |
|
Returns the week obj, given its number and the season year. |
|
Returns the week object for a given datetime. |
- supercontest.dbsession.selects.get_admin() list[User]
Gives list of users with the ‘Admin’ role.
- Returns:
All admin user objects.
- supercontest.dbsession.selects.get_all_users() list[User]
Simply gives the full list of user objects.
- Returns:
All user objects in the database.
- supercontest.dbsession.selects.get_contestants() list[Contestant]
Gets a list of all contestant objects available to the app.
- Returns:
All objects in the contestants table.
- supercontest.dbsession.selects.get_contestants_in_week(season: int, week: int) list[Contestant]
Gets a list of all contestant objects in a given week.
- Parameters:
season – Season year.
week – Week number.
- Returns:
All objects in the contestants table.
- supercontest.dbsession.selects.get_games() list[Game]
Gets a list of all game objects available to the app.
- Returns:
All objects in the games table.
- supercontest.dbsession.selects.get_games_in_season(season: int) list[Game]
Gets a list of all game objects in a given season.
- Parameters:
season – Season year.
- Returns:
All objects in the games table.
- supercontest.dbsession.selects.get_games_in_week(season: int, week: int) list[Game]
Gets a list of all game objects in a given week.
- Parameters:
season – Season year.
week – Week number.
- Returns:
All objects in the games table.
- supercontest.dbsession.selects.get_leagues(season: int | None) list[League]
Get leagues associated with a season.
- Parameters:
season – Season year.
- Returns:
League objects.
- supercontest.dbsession.selects.get_locations() list[Location]
Gets a list of all location objects available to the app.
- Returns:
All objects from the locations table.
- supercontest.dbsession.selects.get_paid_league_for_season(season: int | None) League
Returns the official paid league for a specific season. This is denoted by the league name being “Paid” - if there isn’t one with that name for that season, this errors. If multiple exist (should never happen), this takes the first one. Raises an error (via
one()) if there are no paid leagues for that season.- Parameters:
season – Season year.
- Returns:
The paid league.
- supercontest.dbsession.selects.get_picks() list[Pick]
Gets a list of all pick objects available to the app.
- Returns:
All objects in the picks table.
- supercontest.dbsession.selects.get_picks_in_season(season: int) list[Pick]
Gets a list of all pick objects in a given season.
- Parameters:
season – Season year.
- Returns:
All objects in the picks table.
- supercontest.dbsession.selects.get_picks_in_week(season: int, week: int) list[Pick]
Gets a list of all pick objects in a given week.
- Parameters:
season – Season year.
week – Week number.
- Returns:
All objects in the picks table.
- supercontest.dbsession.selects.get_predictions() list[Prediction]
Gets a list of all prediction objects available to the app.
- Returns:
All objects from the predictions table.
- supercontest.dbsession.selects.get_role_from_name(name: str) Role
Returns the id for a Role row, given its name.
- Parameters:
name – Name of the Role to lookup.
- Returns:
The Role object.
- supercontest.dbsession.selects.get_season_by_time(dt_obj: datetime) Season | None
Returns the season object for a given datetime. This is useful for determining the current season.
- Parameters:
dt_obj – The datetime to check.
- Returns:
The season object.
- supercontest.dbsession.selects.get_sorted_seasons() list[Season]
Numerically sorted season objects, ascending.
- Returns:
All seasons, from oldest to newest.
- supercontest.dbsession.selects.get_sorted_weeks(season: int) list[Week]
Numerically sorted week objects for a season, ascending.
- Parameters:
season – Season year.
- Returns:
All weeks, from oldest to newest.
- supercontest.dbsession.selects.get_statuses() list[Status]
Gets a list of all game status objects available to the app.
- Returns:
All objects in the statuses table.
- supercontest.dbsession.selects.get_team(name: str) Team
Returns the team object, given its name. Compares with
ilike, so the argument can be capitalized, lowered, uppered, etc.- Parameters:
name – The name of the team.
- Returns:
Team object.
- supercontest.dbsession.selects.get_teams() list[Team]
Gets a list of all team objects available to the app.
- Returns:
All objects from the teams table.
- supercontest.dbsession.selects.get_user_from_email(email: str) User
Takes an email, returns a user object. This is case-insensitive. If the email address has been lowered, like the
admin.late_picksform does, it will still find the right user.- Parameters:
email – Email.
- Returns:
The user object.
- supercontest.dbsession.selects.get_users_in_league(league_id: int) list[User]
Returns a list of users in a given league.
- Parameters:
league_id – The league ID.
- Returns:
All users in the league.