diff --git a/service/league_service/league_service.py b/service/league_service/league_service.py index 4d60f8f..30f5f68 100644 --- a/service/league_service/league_service.py +++ b/service/league_service/league_service.py @@ -53,14 +53,11 @@ async def update_data(self): async with self._db.acquire() as conn: sql = ( select( - [ - league_season, - league, - league_season_division, - league_season_division_subdivision, - leaderboard, - ], - use_labels=True, + league_season, + league, + league_season_division, + league_season_division_subdivision, + leaderboard, ) .select_from( league_season_division_subdivision.outerjoin(league_season_division) @@ -148,7 +145,7 @@ async def _rate_single_league(self, league: League, request: LeagueRatingRequest async def _load_score(self, player_id: PlayerID, league: League) -> LeagueScore: async with self._db.acquire() as conn: - sql = select([league_season_score]).where( + sql = select(league_season_score).where( and_( league_season_score.c.login_id == player_id, league_season_score.c.league_season_id == league.current_season_id, @@ -170,7 +167,7 @@ async def _load_score(self, player_id: PlayerID, league: League) -> LeagueScore: async def is_returning_player(self, player_id: PlayerID, rating_type: str) -> bool: async with self._db.acquire() as conn: sql = ( - select([league_season_score]) + select(league_season_score) .select_from( league_season_score.outerjoin(league_season) .outerjoin(leaderboard)) @@ -203,7 +200,7 @@ async def _persist_score( raise InvalidScoreError("Missing score for non-null division.") select_season_id = ( - select([league_season_division.c.league_season_id]) + select(league_season_division.c.league_season_id) .select_from( league_season_division_subdivision.outerjoin( league_season_division diff --git a/service/season_generator.py b/service/season_generator.py index d85d996..b5adbbd 100644 --- a/service/season_generator.py +++ b/service/season_generator.py @@ -26,7 +26,7 @@ def initialize(self): async def check_season_end(self): self._logger.debug("Checking if latest season ends soon.") async with self._db.acquire() as conn: - sql = select([league_season]) + sql = select(league_season) result = await conn.execute(sql) rows = await result.fetchall() @@ -43,7 +43,7 @@ async def check_season_end(self): async def generate_season(self): self._logger.info("Generating new season...") async with self._db.acquire() as conn: - sql = select([league]).where(league.c.enabled == True) + sql = select(league).where(league.c.enabled == True) result = await conn.execute(sql) rows = await result.fetchall() @@ -57,7 +57,7 @@ async def generate_season(self): async def update_db(self, conn, league_row, start_date, end_date): season_sql = ( - select([league_season]) + select(league_season) .where(league_season.c.league_id == league_row[league.c.id]) .order_by(desc(league_season.c.season_number)) .limit(1) @@ -70,7 +70,7 @@ async def update_db(self, conn, league_row, start_date, end_date): league_row[league.c.technical_name] ) return - result = await conn.execute(select([func.max(league_season.c.id)])) + result = await conn.execute(select(func.max(league_season.c.id))) season_id = await result.scalar() + 1 season_number = season_row[league_season.c.season_number] + 1 season_insert_sql = ( @@ -89,7 +89,7 @@ async def update_db(self, conn, league_row, start_date, end_date): await conn.execute(season_insert_sql) division_sql = ( - select([league_season_division]) + select(league_season_division) .where(league_season_division.c.league_season_id == season_row[league_season.c.id]) ) result = await conn.execute(division_sql) @@ -102,7 +102,7 @@ async def update_db(self, conn, league_row, start_date, end_date): season_id ) return - result = await conn.execute(select([func.max(league_season_division.c.id)])) + result = await conn.execute(select(func.max(league_season_division.c.id))) division_id = await result.scalar() for division_row in season_division_rows: division_index = division_row[league_season_division.c.division_index] @@ -122,7 +122,7 @@ async def update_db(self, conn, league_row, start_date, end_date): await conn.execute(division_insert_sql) subdivision_sql = ( - select([league_season_division_subdivision]) + select(league_season_division_subdivision) .where(league_season_division_subdivision.c.league_season_division_id == division_row[league_season_division.c.id]) ) diff --git a/tests/unit_tests/test_league_service.py b/tests/unit_tests/test_league_service.py index f8ad877..3bb5647 100644 --- a/tests/unit_tests/test_league_service.py +++ b/tests/unit_tests/test_league_service.py @@ -183,7 +183,7 @@ async def test_persist_score_new_player(league_service, database): assert loaded_score == new_score async with database.acquire() as conn: - result = await conn.execute(select([league_score_journal])) + result = await conn.execute(select(league_score_journal)) rows = await result.fetchall() assert len(rows) == 1 for row in rows: @@ -215,7 +215,7 @@ async def test_persist_score_old_player(league_service, database): assert loaded_score == new_score async with database.acquire() as conn: - result = await conn.execute(select([league_score_journal])) + result = await conn.execute(select(league_score_journal)) rows = await result.fetchall() assert len(rows) == 1 for row in rows: diff --git a/tests/unit_tests/test_season_generator.py b/tests/unit_tests/test_season_generator.py index a778beb..6146712 100644 --- a/tests/unit_tests/test_season_generator.py +++ b/tests/unit_tests/test_season_generator.py @@ -41,7 +41,7 @@ async def test_season_check_after_season_end(season_generator): async def test_generate_season(season_generator, database): await season_generator.generate_season() async with database.acquire() as conn: - seasons = await conn.execute(select([league_season])) + seasons = await conn.execute(select(league_season)) rows = await seasons.fetchall() assert len(rows) == 6 assert max(row[league_season.c.season_number] for row in rows) == 4 @@ -77,7 +77,7 @@ async def test_generate_season_only_once(season_generator, database): await season_generator.check_season_end() await season_generator.check_season_end() async with database.acquire() as conn: - seasons = await conn.execute(select([league_season])) + seasons = await conn.execute(select(league_season)) rows = await seasons.fetchall() assert len(rows) == 6 assert max(row[league_season.c.season_number] for row in rows) == 4