Add evaluate winner method
This commit is contained in:
parent
072d425ee9
commit
5c6c496d74
|
|
@ -21,6 +21,13 @@ class Match < ApplicationRecord
|
|||
|
||||
private
|
||||
|
||||
def evaluate_winner
|
||||
return nil unless finished?
|
||||
return nil if match_scores.first.points == match_scores.second.points
|
||||
|
||||
match_scores.max_by(&:points).team
|
||||
end
|
||||
|
||||
def stage_xor_group
|
||||
errors.add(:stage_xor_group, 'Stage and Group missing or both present') unless stage.present? ^ group.present?
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue