1919)
2020from bracket .models .db .round import Round
2121from bracket .models .db .user import UserPublic
22+ from bracket .models .db .util import RoundWithMatches
2223from bracket .routes .auth import user_authenticated_for_tournament
2324from bracket .routes .models import SingleMatchResponse , SuccessResponse , UpcomingMatchesResponse
24- from bracket .routes .util import match_dependency , round_dependency
25+ from bracket .routes .util import match_dependency , round_dependency , round_with_matches_dependency
26+ from bracket .sql .courts import get_all_courts_in_tournament
2527from bracket .sql .matches import sql_delete_match , sql_update_match
2628from bracket .utils .types import assert_some
2729
3436)
3537async def get_matches_to_schedule (
3638 tournament_id : int ,
37- elo_diff_threshold : int = 100 ,
39+ elo_diff_threshold : int = 200 ,
3840 iterations : int = 200 ,
3941 only_behind_schedule : bool = False ,
4042 limit : int = 50 ,
@@ -109,7 +111,7 @@ async def create_matches_automatically(
109111 iterations : int = 200 ,
110112 only_behind_schedule : bool = False ,
111113 _ : UserPublic = Depends (user_authenticated_for_tournament ),
112- round_ : Round = Depends (round_dependency ),
114+ round_ : RoundWithMatches = Depends (round_with_matches_dependency ),
113115) -> SuccessResponse :
114116 if not round_ .is_draft :
115117 raise HTTPException (400 , 'There is no draft round, so no matches can be scheduled.' )
@@ -120,8 +122,9 @@ async def create_matches_automatically(
120122 limit = 1 ,
121123 iterations = iterations ,
122124 )
125+ courts = await get_all_courts_in_tournament (tournament_id )
123126
124- limit = 15
127+ limit = len ( courts ) - len ( round_ . matches )
125128 for __ in range (limit ):
126129 all_matches_to_schedule = await get_upcoming_matches_for_swiss_round (
127130 match_filter , round_ , tournament_id
0 commit comments