Only support stage count calculation for 1+ teams

This commit is contained in:
Daniel Schädler 2019-04-18 14:19:19 +02:00
parent d221928a12
commit 38425df823
1 changed files with 2 additions and 2 deletions

View File

@ -61,8 +61,8 @@ class PlayoffStageService
# @param number_of_teams [Integer] the teams number of teams to calculate amount of stages # @param number_of_teams [Integer] the teams number of teams to calculate amount of stages
# @return [Integer] amount of required stages # @return [Integer] amount of required stages
def self.calculate_required_stage_count(number_of_teams) def self.calculate_required_stage_count(number_of_teams)
if number_of_teams.zero? || number_of_teams == 1 if number_of_teams == 1
0 1
else else
# black voodoo magic # black voodoo magic
stage_count = Math.log(Utils.next_power_of_two(number_of_teams)) / Math.log(2) stage_count = Math.log(Utils.next_power_of_two(number_of_teams)) / Math.log(2)