Fix broadcast issue

clubs
Laurent 2 years ago
parent 3197938fa0
commit f4cb610b57
  1. 20
      tournaments/models/round.py
  2. 6
      tournaments/models/tournament.py

@ -35,13 +35,27 @@ class Round(models.Model):
child_matches = child.match_set.all() child_matches = child.match_set.all()
if hide_empty_matches: if hide_empty_matches:
child_matches = [m for m in matches if m.should_appear()] child_matches = [m for m in child_matches if m.should_appear()]
matches.extend(child_matches) matches.extend(child_matches)
matches.extend(child.ranking_matches(hide_empty_matches)) matches.extend(child.ranking_matches(hide_empty_matches))
return matches return matches
def all_matches(self): def all_matches(self):
matches = list(self.match_set.all()) matches = []
matches.extend(self.ranking_matches(True)) matches.extend(self.match_set.all())
matches.extend(self.get_matches_recursive(False))
return matches
def get_matches_recursive(self, hide_empty_matches):
matches = list(self.match_set.all()) # Retrieve matches associated with the current round
if hide_empty_matches:
matches = [m for m in matches if m.should_appear()]
# Recursively fetch matches from child rounds
for child_round in self.children.all():
matches.extend(child_round.get_matches_recursive(hide_empty_matches))
# print(f"{self.name()} > COUNT REC = {len(matches)}")
return matches return matches

@ -175,8 +175,8 @@ class Tournament(models.Model):
previous_round = self.round_for_index(current_round.index + 1) previous_round = self.round_for_index(current_round.index + 1)
if previous_round: if previous_round:
matches.extend(current_round.all_matches()) matches.extend(current_round.get_matches_recursive(False))
matches.extend(previous_round.all_matches()) matches.extend(previous_round.get_matches_recursive(False))
else: else:
matches.extend(current_round.all_matches()) matches.extend(current_round.all_matches())
group_stages = self.live_group_stages() group_stages = self.live_group_stages()
@ -199,7 +199,7 @@ class Tournament(models.Model):
return matches[0] return matches[0]
def round_for_index(self, index): def round_for_index(self, index):
return self.round_set.filter(index=index).first() return self.round_set.filter(index=index,loser=None).first()
def group_stages_matches(self): def group_stages_matches(self):
matches = [] matches = []

Loading…
Cancel
Save