Merge branch 'ticket/TUR-9' into 'master'
TUR-9: Support upcoming match stage See merge request turniere/turniere-backend!22
This commit is contained in:
commit
48d3d3c174
|
|
@ -10,6 +10,23 @@ class MatchesController < ApplicationController
|
||||||
def index
|
def index
|
||||||
matches = if match_params['state'].nil?
|
matches = if match_params['state'].nil?
|
||||||
@tournament.matches
|
@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
|
else
|
||||||
@tournament.matches.select do |m|
|
@tournament.matches.select do |m|
|
||||||
m.state == match_params['state']
|
m.state == match_params['state']
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,12 @@
|
||||||
tmp/restart.txt
|
tmp/restart.txt
|
||||||
tmp/caching-dev.txt
|
tmp/caching-dev.txt
|
||||||
].each { |path| Spring.watch(path) }
|
].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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue