diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 71abf28..ae1de80 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -10,6 +10,23 @@ class MatchesController < ApplicationController def index matches = if match_params['state'].nil? @tournament.matches + + # support for upcoming matches for beamer view + elsif match_params['state'] == 'upcoming' + # for every group within the tournament find the match with the lowest position that is of state 'not_started' + upcoming_matches = @tournament.stages.find_by(level: -1)&.groups&.map { |g| g.matches.select { |m| m.state == 'not_started' }.min_by(&:position) } + # if there are none, the group stage is over, so we have to look into the playoff stages + if upcoming_matches.nil? + next_level = 0 + @tournament.stages.sort_by(&:level).reverse_each do |stage| + # 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 + end + @tournament.stages.find_by(level: next_level).matches + end else @tournament.matches.select do |m| m.state == match_params['state'] diff --git a/config/spring.rb b/config/spring.rb index c5933e4..2be7406 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -6,3 +6,12 @@ tmp/restart.txt tmp/caching-dev.txt ].each { |path| Spring.watch(path) } + +Spring.after_fork do + if ENV['DEBUGGER_STORED_RUBYLIB'] + ENV['DEBUGGER_STORED_RUBYLIB'].split(File::PATH_SEPARATOR).each do |path| + next unless path =~ /ruby-debug-ide/ + load path + '/ruby-debug-ide/multiprocess/starter.rb' + end + end +end