mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
25 lines
667 B
Ruby
25 lines
667 B
Ruby
class Teampointadjust < ApplicationRecord
|
|
belongs_to :wrestler, touch: true, optional: true
|
|
belongs_to :school, touch: true, optional: true
|
|
|
|
after_save do
|
|
advance_wrestlers_and_calc_team_score
|
|
end
|
|
|
|
after_destroy do
|
|
advance_wrestlers_and_calc_team_score
|
|
end
|
|
|
|
def advance_wrestlers_and_calc_team_score
|
|
#Team score needs calculated
|
|
if self.wrestler_id != nil
|
|
#In case this affects pool order
|
|
AdvanceWrestler.new(self.wrestler,self.wrestler.last_match).advance
|
|
self.wrestler.school.calculate_score
|
|
elsif self.school_id != nil
|
|
self.school.calculate_score
|
|
end
|
|
end
|
|
|
|
end
|