fix LB sorting

online_registration
Raz 1 year ago
parent ab37b7b189
commit e797135ee5
  1. 5
      tournaments/models/round.py
  2. 8
      tournaments/models/tournament.py

@ -67,10 +67,7 @@ class Round(models.Model):
matches.sort(key=lambda m: m.index)
# Recursively fetch matches from child rounds
# Sort children by depth in ascending order (deeper rounds last)
sorted_children = sorted(self.children.all(), key=lambda child: (child.index, child.get_depth()))
for child_round in sorted_children:
for child_round in self.children.all():
matches.extend(child_round.get_matches_recursive(hide_empty_matches))
return matches

@ -469,7 +469,13 @@ class Tournament(models.Model):
ranking_matches = [m for m in ranking_matches if m.disabled is False]
if len(ranking_matches) > 0:
ranking_matches.sort(key=lambda m: m.index)
ranking_matches.sort(
key=lambda m: (
m.round.index, # Sort by Round index first
m.round.get_depth(),
m.name, # Then by Round depth
)
)
group = self.create_match_group('Matchs de classement', ranking_matches)
groups.append(group)

Loading…
Cancel
Save