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

get_admin

Gives list of users with the 'Admin' role.

get_all_users

Simply gives the full list of user objects.

get_contestants

Gets a list of all contestant objects available to the app.

get_contestants_in_week

Gets a list of all contestant objects in a given week.

get_games

Gets a list of all game objects available to the app.

get_games_in_season

Gets a list of all game objects in a given season.

get_games_in_week

Gets a list of all game objects in a given week.

get_leagues

Get leagues associated with a season.

get_locations

Gets a list of all location objects available to the app.

get_paid_league_for_season

Returns the official paid league for a specific season.

get_picks

Gets a list of all pick objects available to the app.

get_picks_in_season

Gets a list of all pick objects in a given season.

get_picks_in_week

Gets a list of all pick objects in a given week.

get_predictions

Gets a list of all prediction objects available to the app.

get_role_from_name

Returns the id for a Role row, given its name.

get_season_by_time

Returns the season object for a given datetime.

get_sorted_seasons

Numerically sorted season objects, ascending.

get_sorted_weeks

Numerically sorted week objects for a season, ascending.

get_statuses

Gets a list of all game status objects available to the app.

get_team

Returns the team object, given its name.

get_teams

Gets a list of all team objects available to the app.

get_user_from_email

Takes an email, returns a user object.

get_users_in_league

Returns a list of users in a given league.

get_week

Returns the week obj, given its number and the season year.

get_week_by_time

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_picks form 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.

supercontest.dbsession.selects.get_week(season: int | None, week: int | None) Week

Returns the week obj, given its number and the season year.

Parameters:
  • season – Season year.

  • week – Week number.

Returns:

Week obj.

supercontest.dbsession.selects.get_week_by_time(dt_obj: datetime) Week | None

Returns the week object for a given datetime. This is useful for determining the current week.

Parameters:

dt_obj – The datetime to check.

Returns:

The week object.