Skip to content

Commit a04bfd7

Browse files
authored
Revert round/match JOINs, keep only and→& for team and courts
1 parent 3bc663b commit a04bfd7

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

backend/bracket/routes/util.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from bracket.models.db.team import FullTeamWithPlayers, Team
88
from bracket.models.db.tournament import Tournament, TournamentStatus
99
from bracket.models.db.util import RoundWithMatches, StageItemWithRounds, StageWithStageItems
10-
from bracket.schema import matches, rounds, stage_items, stages, teams
10+
from bracket.schema import matches, rounds, teams
1111
from bracket.sql.rounds import get_round_by_id
1212
from bracket.sql.stage_items import get_stage_item
1313
from bracket.sql.stages import get_full_tournament_details
@@ -21,13 +21,7 @@ async def round_dependency(tournament_id: TournamentId, round_id: RoundId) -> Ro
2121
round_ = await fetch_one_parsed(
2222
database,
2323
Round,
24-
rounds.select()
25-
.select_from(
26-
rounds.join(stage_items, rounds.c.stage_item_id == stage_items.c.id).join(
27-
stages, stage_items.c.stage_id == stages.c.id
28-
)
29-
)
30-
.where((rounds.c.id == round_id) & (stages.c.tournament_id == tournament_id)),
24+
rounds.select().where(rounds.c.id == round_id and matches.c.tournament_id == tournament_id),
3125
)
3226

3327
if round_ is None:
@@ -69,13 +63,9 @@ async def match_dependency(tournament_id: TournamentId, match_id: MatchId) -> Ma
6963
match = await fetch_one_parsed(
7064
database,
7165
Match,
72-
matches.select()
73-
.select_from(
74-
matches.join(rounds, matches.c.round_id == rounds.c.id)
75-
.join(stage_items, rounds.c.stage_item_id == stage_items.c.id)
76-
.join(stages, stage_items.c.stage_id == stages.c.id)
77-
)
78-
.where((matches.c.id == match_id) & (stages.c.tournament_id == tournament_id)),
66+
matches.select().where(
67+
matches.c.id == match_id and matches.c.tournament_id == tournament_id
68+
),
7969
)
8070

8171
if match is None:

0 commit comments

Comments
 (0)