Label fixes, Websocket reconnects and more detailed court view cards.

This commit is contained in:
2026-06-14 20:57:19 +02:00 Verified
parent b904879326
commit 55a13934ef
8 changed files with 222 additions and 76 deletions
+7 -10
View File
@@ -95,6 +95,7 @@ def update_schedule_times(db: Session, t: models.Tournament):
models.Tournament.timestamp >= start_of_day,
models.Tournament.timestamp < end_of_day,
)
.with_for_update()
.all()
)
@@ -296,6 +297,8 @@ def update_schedule_times(db: Session, t: models.Tournament):
best_score = float("inf")
for prev_m in all_matches:
if prev_m.tournament_id != m.tournament_id:
continue
if not prev_m.start_time or prev_m.start_time >= m_start:
continue
prev_end = prev_m.start_time + timedelta(minutes=prev_m.tournament.duration)
@@ -307,10 +310,7 @@ def update_schedule_times(db: Session, t: models.Tournament):
next_start = match_outcome_next_start.get(out_key)
if next_start and next_start < m_end:
continue
role_str = "Winner" if outcome == "W" else "Loser"
identifier = f"{role_str} of #{prev_m.match_number}"
identifier = f"{outcome}:{prev_m.id}"
if is_ref_busy(identifier, m_start, m_end):
continue
@@ -363,10 +363,10 @@ def advance_winner(db: Session, match: models.Match, winner_id: int):
loser_id = match.p1_team_id if match.p1_team_id != winner_id else match.p2_team_id
for m in match.tournament.matches:
if m.ref_label == f"Loser of #{match.match_number}":
if m.ref_label == f"L:{match.id}":
m.ref_team_id = loser_id
db.add(m)
elif m.ref_label == f"Winner of #{match.match_number}":
elif m.ref_label == f"W:{match.id}":
m.ref_team_id = winner_id
db.add(m)
@@ -435,10 +435,7 @@ def undo_advancement(db: Session, match: models.Match):
return
for m in match.tournament.matches:
if (
m.ref_label == f"Loser of #{match.match_number}"
or m.ref_label == f"Winner of #{match.match_number}"
):
if m.ref_label in [f"L:{match.id}", f"W:{match.id}"]:
m.ref_team_id = None
db.add(m)