TUR-9: Alter match filter for playoff stage to how it probably was meant to be

This commit is contained in:
Daniel Schädler 2022-05-20 09:41:01 +02:00
parent 3c038ee9c9
commit ead6d4f475
Signed by: Malaber
GPG Key ID: 4BB175A9617E4B11
1 changed files with 2 additions and 4 deletions

View File

@ -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