WIP
This commit is contained in:
parent
1598db7796
commit
1d2b80e105
|
|
@ -10,6 +10,18 @@ class MatchesController < ApplicationController
|
||||||
def index
|
def index
|
||||||
matches = if match_params['state'].nil?
|
matches = if match_params['state'].nil?
|
||||||
@tournament.matches
|
@tournament.matches
|
||||||
|
elsif match_params['state'] == 'upcoming'
|
||||||
|
upcoming_matches = @tournament.stages.find_by(level: -1)&.groups&.map { |g| g.matches.select { |m| m.state == 'not_started' }.min_by(&:position) }
|
||||||
|
if upcoming_matches.nil?
|
||||||
|
next_level = 0
|
||||||
|
@tournament.stages.sort_by(&:level).reverse_each do |stage|
|
||||||
|
if stage.matches.reject { |m| m.state == 'running' }.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']
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue