diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 086dae1..1541ea6 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -427,11 +427,20 @@ class Tournament(models.Model): if len(self.groupstage_set.all()) > 0 and self.no_bracket_match_has_started(): group_stages = self.live_group_stages() matches = self.broadcasted_group_stages_matches() + first_round = self.first_round() + if first_round: + matches.extend(first_round.get_matches_recursive(True)) else: current_round = self.round_to_show() if current_round: - previous_round = self.round_for_index(current_round.index + 1) + # Add full matches from the next rounds + next_round = self.round_for_index(current_round.index - 1) + if next_round: + matches.extend(next_round.get_matches_recursive(True)) + + # Add matches from the previous round or group_stages + previous_round = self.round_for_index(current_round.index + 1) if previous_round: matches.extend(current_round.get_matches_recursive(True)) matches.extend(previous_round.get_matches_recursive(True)) @@ -504,6 +513,11 @@ class Tournament(models.Model): def round_for_index(self, index): return self.round_set.filter(index=index, parent=None).first() + def first_round(self): + main_rounds = list(self.round_set.filter(parent=None)) + main_rounds.sort(key=lambda r: r.index, reverse=True) + return main_rounds[0] + def broadcasted_group_stages_matches(self): matches = [] group_stages = self.elected_broadcast_group_stages()