From f7ed4b549d684da7071ffd5bc5af97eb916e0c08 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Sat, 4 May 2019 20:54:08 +0200 Subject: [PATCH] Destroying all Readability. Noone will ever be able to read this code again. --- app/services/group_stage_service.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/services/group_stage_service.rb b/app/services/group_stage_service.rb index 0c2b7d7..ea03168 100644 --- a/app/services/group_stage_service.rb +++ b/app/services/group_stage_service.rb @@ -4,22 +4,21 @@ class GroupStageService def self.generate_group_stage(groups) raise 'Cannot generate group stage without groups' if groups.length.zero? - average_group_size = (groups.flatten.length.to_f / groups.length.to_f) - raise 'Groups need to be equal size' unless (average_group_size % 1).zero? + # raise an error if the average group size is not a whole number + raise 'Groups need to be equal size' unless (groups.flatten.length.to_f / groups.length.to_f % 1).zero? groups = groups.map(&method(:get_group_object_from)) Stage.new level: -1, groups: groups end def self.get_group_object_from(team_array) - matches = generate_all_matches_between team_array - Group.new matches: matches + Group.new matches: generate_all_matches_between(team_array) end def self.generate_all_matches_between(teams) matches = [] - matchups = teams.combination(2).to_a - matchups.each_with_index do |matchup, i| + teams.combination(2).to_a # = matchups + .each_with_index do |matchup, i| match = Match.new state: :not_started, position: i, match_scores: [