diff --git a/service/league_service/league_service.py b/service/league_service/league_service.py index 30f5f68..90255cd 100644 --- a/service/league_service/league_service.py +++ b/service/league_service/league_service.py @@ -68,7 +68,7 @@ async def update_data(self): .where(between(datetime.now(), league_season.c.start_date, league_season.c.end_date)) ) result = await conn.execute(sql) - division_rows = await result.fetchall() + division_rows = result.fetchall() # The concept of subdivisions exists only in the database and client, # but not in the rating service. We therefore treat every subdivision @@ -152,7 +152,7 @@ async def _load_score(self, player_id: PlayerID, league: League) -> LeagueScore: ) ) result = await conn.execute(sql) - row = await result.fetchone() + row = result.fetchone() if row is None: returning_player = await self.is_returning_player(player_id, league.rating_type) return LeagueScore(None, None, 0, returning_player) @@ -179,7 +179,7 @@ async def is_returning_player(self, player_id: PlayerID, rating_type: str) -> bo ) ) result = await conn.execute(sql) - row = await result.fetchone() + row = result.fetchone() if row is None or row[league_season_score.c.subdivision_id] is None: return False else: @@ -211,7 +211,7 @@ async def _persist_score( ) ) result = await conn.execute(select_season_id) - row = await result.fetchone() + row = result.fetchone() season_id_of_division = row.get("league_season_id") if season_id != season_id_of_division: raise InvalidScoreError("Division id did not match season id.") diff --git a/service/season_generator.py b/service/season_generator.py index b5adbbd..9ce0e16 100644 --- a/service/season_generator.py +++ b/service/season_generator.py @@ -28,7 +28,7 @@ async def check_season_end(self): async with self._db.acquire() as conn: sql = select(league_season) result = await conn.execute(sql) - rows = await result.fetchall() + rows = result.fetchall() max_date = max(row[league_season.c.end_date] for row in rows) @@ -45,7 +45,7 @@ async def generate_season(self): async with self._db.acquire() as conn: sql = select(league).where(league.c.enabled == True) result = await conn.execute(sql) - rows = await result.fetchall() + rows = result.fetchall() next_month = datetime.now() + relativedelta(months=1) # season starts and ends at noon, so that all timezones see the same date in the client @@ -63,7 +63,7 @@ async def update_db(self, conn, league_row, start_date, end_date): .limit(1) ) result = await conn.execute(season_sql) - season_row = await result.fetchone() + season_row = result.fetchone() if season_row is None: self._logger.warning( "No season found for league %s. Skipping this league", @@ -71,7 +71,7 @@ async def update_db(self, conn, league_row, start_date, end_date): ) return result = await conn.execute(select(func.max(league_season.c.id))) - season_id = await result.scalar() + 1 + season_id = result.scalar() + 1 season_number = season_row[league_season.c.season_number] + 1 season_insert_sql = ( insert(league_season) @@ -93,7 +93,7 @@ async def update_db(self, conn, league_row, start_date, end_date): .where(league_season_division.c.league_season_id == season_row[league_season.c.id]) ) result = await conn.execute(division_sql) - season_division_rows = await result.fetchall() + season_division_rows = result.fetchall() if not season_division_rows: self._logger.warning( "No divisions found for season id %s. No divisions could be created. " @@ -103,7 +103,7 @@ async def update_db(self, conn, league_row, start_date, end_date): ) return result = await conn.execute(select(func.max(league_season_division.c.id))) - division_id = await result.scalar() + division_id = result.scalar() for division_row in season_division_rows: division_index = division_row[league_season_division.c.division_index] division_id += 1 @@ -127,7 +127,7 @@ async def update_db(self, conn, league_row, start_date, end_date): division_row[league_season_division.c.id]) ) result = await conn.execute(subdivision_sql) - subdivision_rows = await result.fetchall() + subdivision_rows = result.fetchall() if not subdivision_rows: self._logger.warning( "No subdivisions found for division id %s. No subdivisions could be created. " diff --git a/tests/unit_tests/test_league_service.py b/tests/unit_tests/test_league_service.py index 3bb5647..832bbfe 100644 --- a/tests/unit_tests/test_league_service.py +++ b/tests/unit_tests/test_league_service.py @@ -184,7 +184,7 @@ async def test_persist_score_new_player(league_service, database): async with database.acquire() as conn: result = await conn.execute(select(league_score_journal)) - rows = await result.fetchall() + rows = result.fetchall() assert len(rows) == 1 for row in rows: assert row["game_id"] == 1 @@ -216,7 +216,7 @@ async def test_persist_score_old_player(league_service, database): async with database.acquire() as conn: result = await conn.execute(select(league_score_journal)) - rows = await result.fetchall() + rows = result.fetchall() assert len(rows) == 1 for row in rows: assert row["game_id"] == 10