Refactors Stage.teams to return empty list if no teams are found

This commit is contained in:
Daniel Schädler 2019-05-07 11:36:28 +02:00
parent f7ed4b549d
commit 2ac55c898f
1 changed files with 6 additions and 2 deletions

View File

@ -6,8 +6,12 @@ class Stage < ApplicationRecord
has_many :groups, dependent: :destroy
def teams
return matches.map(&:teams).flatten.uniq unless matches.size.zero?
if groups.size.zero?
return matches.map(&:teams).flatten.uniq
elsif matches.size.zero?
return groups.map(&:teams).flatten.uniq
end
groups.map(&:teams).flatten.uniq unless groups.size.zero?
[]
end
end