1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Added before save on wrestler and weight. Also fixed fourPoolNumbers for weight

This commit is contained in:
2015-03-28 18:16:32 +00:00
parent 43d7089b44
commit 9976fd5869
2 changed files with 35 additions and 1 deletions

View File

@@ -4,6 +4,11 @@ class Weight < ActiveRecord::Base
attr_accessor :pools, :bracket_size, :bracket_type, :poolRounds, :totalRounds
before_save do
self.tournament.matchups_array = nil
self.tournament.save
end
def pools
@wrestlers = self.wrestlers
if @wrestlers.size <= 6
@@ -57,6 +62,29 @@ class Weight < ActiveRecord::Base
end
return wrestlers
end
def fourPoolNumbers(wrestlers)
pool = 1
wrestlers.sort_by{|x|[x.original_seed]}.reverse.each do |w|
if w.original_seed == 1
w.poolNumber = 1
elsif w.original_seed == 2
w.poolNumber = 2
elsif w.original_seed == 3
w.poolNumber = 3
elsif w.original_seed == 4
w.poolNumber = 4
else
w.poolNumber = pool
end
if pool < 4
pool = pool + 1
else
pool =1
end
end
return wrestlers
end
def bracket_size
@wrestlers = Wrestler.where(weight_id: self.id)

View File

@@ -2,8 +2,14 @@ class Wrestler < ActiveRecord::Base
belongs_to :school
belongs_to :weight
has_one :tournament, through: :weight
attr_accessor :allMatches, :isWrestlingThisRound, :boutByRound, :seasonWinPercentage
attr_accessor :allMatches, :isWrestlingThisRound, :boutByRound, :seasonWinPercentage, :poolNumber
before_save do
self.tournament.matchups_array = nil
self.tournament.save
end
def isWrestlingThisRound(matchRound)
@gMatches = Match.where(g_id: self.id, round: matchRound)
@rMatches = Match.where(r_id: self.id, round: matchRound)