mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-05 22:21:26 +00:00
A ton of stuff was done to finalize the app for use
This commit is contained in:
4
app/models/mat.rb
Normal file
4
app/models/mat.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class Mat < ActiveRecord::Base
|
||||
belongs_to :tournament
|
||||
has_many :weights, dependent: :destroy
|
||||
end
|
||||
@@ -1,3 +1,4 @@
|
||||
class Match < ActiveRecord::Base
|
||||
belongs_to :tournament
|
||||
WIN_TYPES = ["Decision", "Major", "Tech Fall", "Pin", "Forfeit", "Injury Default", "Default"]
|
||||
end
|
||||
|
||||
@@ -3,11 +3,27 @@ class School < ActiveRecord::Base
|
||||
has_many :wrestlers, dependent: :destroy
|
||||
|
||||
#calculate score here
|
||||
#def score
|
||||
# @score = 0
|
||||
# self.wrestlers.each do |w|
|
||||
# @score = @score + w.season_win * 2
|
||||
# end
|
||||
# self.score = @score
|
||||
#end
|
||||
def score
|
||||
@score = 0
|
||||
self.wrestlers.each do |wrestler|
|
||||
@match_wins = Match.where(winner_id: wrestler.id)
|
||||
@match_wins.each do |m|
|
||||
@score = @score + 2
|
||||
if m.win_type == "Major"
|
||||
@score = @score + 1
|
||||
elsif m.win_type == "Tech Fall"
|
||||
@score = @score + 1.5
|
||||
elsif m.win_type == "Pin"
|
||||
@score = @score + 2
|
||||
elsif m.win_type == "Forfeit"
|
||||
@score = @score + 2
|
||||
elsif m.win_type == "Injury Default"
|
||||
@score = @score + 2
|
||||
elsif m.win_type == "Default"
|
||||
@score = @score + 2
|
||||
end
|
||||
end
|
||||
end
|
||||
self.score = @score
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,5 +2,5 @@ class Tournament < ActiveRecord::Base
|
||||
has_many :schools, dependent: :destroy
|
||||
has_many :weights, dependent: :destroy
|
||||
has_many :matches, dependent: :destroy
|
||||
|
||||
has_many :mats, dependent: :destroy
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user