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:
@@ -4,6 +4,11 @@ class Weight < ActiveRecord::Base
|
|||||||
|
|
||||||
attr_accessor :pools, :bracket_size, :bracket_type, :poolRounds, :totalRounds
|
attr_accessor :pools, :bracket_size, :bracket_type, :poolRounds, :totalRounds
|
||||||
|
|
||||||
|
before_save do
|
||||||
|
self.tournament.matchups_array = nil
|
||||||
|
self.tournament.save
|
||||||
|
end
|
||||||
|
|
||||||
def pools
|
def pools
|
||||||
@wrestlers = self.wrestlers
|
@wrestlers = self.wrestlers
|
||||||
if @wrestlers.size <= 6
|
if @wrestlers.size <= 6
|
||||||
@@ -57,6 +62,29 @@ class Weight < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
return wrestlers
|
return wrestlers
|
||||||
end
|
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
|
def bracket_size
|
||||||
@wrestlers = Wrestler.where(weight_id: self.id)
|
@wrestlers = Wrestler.where(weight_id: self.id)
|
||||||
|
|||||||
@@ -2,8 +2,14 @@ class Wrestler < ActiveRecord::Base
|
|||||||
belongs_to :school
|
belongs_to :school
|
||||||
belongs_to :weight
|
belongs_to :weight
|
||||||
has_one :tournament, through: :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)
|
def isWrestlingThisRound(matchRound)
|
||||||
@gMatches = Match.where(g_id: self.id, round: matchRound)
|
@gMatches = Match.where(g_id: self.id, round: matchRound)
|
||||||
@rMatches = Match.where(r_id: self.id, round: matchRound)
|
@rMatches = Match.where(r_id: self.id, round: matchRound)
|
||||||
|
|||||||
Reference in New Issue
Block a user