From 8c39fa989491d9dca0baa07239fb7067217f4508 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Fri, 8 Nov 2019 23:51:23 +0100 Subject: [PATCH 1/2] Manually sort position of groups of 4 teams --- app/services/group_stage_service.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/services/group_stage_service.rb b/app/services/group_stage_service.rb index 6490980..1b3b85a 100644 --- a/app/services/group_stage_service.rb +++ b/app/services/group_stage_service.rb @@ -17,6 +17,13 @@ class GroupStageService group_scores: team_array.map { |team| GroupScore.new team: team } end + def deal_with_spacing_of_teams(matches, team_size) + if team_size == 4 + matches[2].position, matches[4].position = matches[4].position, matches[2].position + matches + end + end + def generate_all_matches_between(teams) matches = [] teams.combination(2).to_a # = matchups @@ -29,7 +36,7 @@ class GroupStageService ] matches << match end - matches + deal_with_spacing_of_teams(matches, teams.size) end # Updates all group_scores of the given group From 1a96cefbc829af9e775d8d3747bdad52596d5cc1 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Sat, 9 Nov 2019 00:00:43 +0100 Subject: [PATCH 2/2] Guard clause to make Hound woof --- app/services/group_stage_service.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/services/group_stage_service.rb b/app/services/group_stage_service.rb index 1b3b85a..71011f0 100644 --- a/app/services/group_stage_service.rb +++ b/app/services/group_stage_service.rb @@ -18,10 +18,10 @@ class GroupStageService end def deal_with_spacing_of_teams(matches, team_size) - if team_size == 4 - matches[2].position, matches[4].position = matches[4].position, matches[2].position - matches - end + return unless team_size == 4 + + matches[2].position, matches[4].position = matches[4].position, matches[2].position + matches end def generate_all_matches_between(teams)