mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-08 07:22:38 +00:00
Refactored names of methods and some db column
This commit is contained in:
@@ -7,11 +7,11 @@ class School < ActiveRecord::Base
|
||||
validates :name, presence: true
|
||||
|
||||
before_destroy do
|
||||
self.tournament.destroyAllMatches
|
||||
self.tournament.destroy_all_matches
|
||||
end
|
||||
|
||||
#calculate score here
|
||||
def pageScore
|
||||
def page_score_string
|
||||
if self.score == nil
|
||||
return 0.0
|
||||
else
|
||||
@@ -19,26 +19,26 @@ class School < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def calcScore
|
||||
newScore = totalWrestlerPoints - totalDeductedPoints
|
||||
def calculate_score
|
||||
newScore = total_points_scored_by_wrestlers - total_points_deducted
|
||||
self.score = newScore
|
||||
self.save
|
||||
end
|
||||
if Rails.env.production?
|
||||
handle_asynchronously :calcScore
|
||||
handle_asynchronously :calculate_score
|
||||
end
|
||||
|
||||
def totalWrestlerPoints
|
||||
def total_points_scored_by_wrestlers
|
||||
points = 0
|
||||
self.wrestlers.each do |w|
|
||||
if w.extra != true
|
||||
points = points + w.totalTeamPoints
|
||||
points = points + w.total_team_points
|
||||
end
|
||||
end
|
||||
points
|
||||
end
|
||||
|
||||
def totalDeductedPoints
|
||||
def total_points_deducted
|
||||
points = 0
|
||||
deductedPoints.each do |d|
|
||||
points = points + d.points
|
||||
|
||||
Reference in New Issue
Block a user