From e184c76083f62e7e21b5f2b89edff796a3112b0c Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Sat, 9 Nov 2019 00:42:17 +0100 Subject: [PATCH 1/6] WIP --- app/controllers/matches_controller.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 71abf28..e6be7e0 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -10,6 +10,18 @@ class MatchesController < ApplicationController def index matches = if match_params['state'].nil? @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 @tournament.matches.select do |m| m.state == match_params['state'] From 22ab1eb69b5b9008afadc9c676685d33e2e03086 Mon Sep 17 00:00:00 2001 From: Malaber Date: Thu, 19 May 2022 23:51:56 +0200 Subject: [PATCH 2/6] TUR-9: Remove unnecessary reject (this never did anything; there is no state "running") --- app/controllers/matches_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index e6be7e0..d898fbc 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -15,7 +15,7 @@ class MatchesController < ApplicationController 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? + if stage.matches.nil? next_level = stage.level - 1 break end From afa9a26d93d0530e45460062f2dea6368a642fbd Mon Sep 17 00:00:00 2001 From: Malaber Date: Fri, 20 May 2022 00:17:15 +0200 Subject: [PATCH 3/6] Add documentation to upcoming matches filter --- app/controllers/matches_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index d898fbc..d5e06e5 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -10,11 +10,18 @@ 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| + # 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? next_level = stage.level - 1 break From 3282d2d29e737bc14debe92b563186575af3de9e Mon Sep 17 00:00:00 2001 From: Malaber Date: Fri, 20 May 2022 00:17:47 +0200 Subject: [PATCH 4/6] Add debugger config --- config/spring.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/spring.rb b/config/spring.rb index c5933e4..dfdb44f 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -6,3 +6,11 @@ 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 \ No newline at end of file From 3c038ee9c981e53d60a833b7cae043d5074dba71 Mon Sep 17 00:00:00 2001 From: Malaber Date: Fri, 20 May 2022 09:28:32 +0200 Subject: [PATCH 5/6] Add newlines to spring.rb --- config/spring.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/spring.rb b/config/spring.rb index dfdb44f..2be7406 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -6,6 +6,7 @@ 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| @@ -13,4 +14,4 @@ Spring.after_fork do load path + '/ruby-debug-ide/multiprocess/starter.rb' end end -end \ No newline at end of file +end From ead6d4f4753a1ff81c220d483c9b43ccfd6cd5ec Mon Sep 17 00:00:00 2001 From: Malaber Date: Fri, 20 May 2022 09:41:01 +0200 Subject: [PATCH 6/6] 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