From ead6d4f4753a1ff81c220d483c9b43ccfd6cd5ec Mon Sep 17 00:00:00 2001 From: Malaber Date: Fri, 20 May 2022 09:41:01 +0200 Subject: [PATCH] TUR-9: Alter match filter for playoff stage to how it probably was meant to be --- app/controllers/matches_controller.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index d5e06e5..ae1de80 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -19,10 +19,8 @@ class MatchesController < ApplicationController if upcoming_matches.nil? next_level = 0 @tournament.stages.sort_by(&:level).reverse_each do |stage| - # matches in the playoffs are only generated after one of the parent matches are done, so the stages - # which are currently not running are empty, the first empty stage that is found is directly after - # the currently running one, so we subtract 1 and call it a day - if stage.matches.nil? + # the following if equates to true if it finds a stage where all matches are of state `in_progress` + if stage.matches.reject { |m| m.state == 'in_progress' }.nil? next_level = stage.level - 1 break end