1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-07 06:54:16 +00:00

Formatting code and deleting uneeded methods

This commit is contained in:
2015-03-28 14:43:14 +00:00
parent 7b5ffaff29
commit d7bbd32460
2 changed files with 6 additions and 31 deletions

View File

@@ -27,35 +27,11 @@ class Weight < ActiveRecord::Base
return @wrestler.poolNumber return @wrestler.poolNumber
end end
def fourPoolNumbers(wrestlers)
@pool = 1
wrestlers.sort_by{|x|[x.original_seed]}.reverse.each do |w|
if w.original_seed == 3
w.poolNumber = 3
elsif w.original_seed == 4
w.poolNumber = 4
elsif w.original_seed == 1
w.poolNumber = 1
elsif w.original_seed == 2
w.poolNumber = 2
else
w.poolNumber = @pool
end
if @pool < 4
@pool = @pool + 1
else
@pool =1
end
end
return wrestlers
end
def onePoolNumbers(wrestlers) def onePoolNumbers(wrestlers)
wrestlers.sort_by{|x|[x.original_seed]}.each do |w| wrestlers.sort_by{|x|[x.original_seed]}.each do |w|
w.poolNumber = 1 w.poolNumber = 1
end end
return wrestlers return wrestlers
end end

View File

@@ -1,7 +1,7 @@
class Wrestler < ActiveRecord::Base class Wrestler < ActiveRecord::Base
belongs_to :school belongs_to :school
belongs_to :weight belongs_to :weight
attr_accessor :matches_all, :isWrestlingThisRound, :boutByRound, :seasonWinPercentage, :poolNumber attr_accessor :allMatches, :isWrestlingThisRound, :boutByRound, :seasonWinPercentage
def isWrestlingThisRound(matchRound) def isWrestlingThisRound(matchRound)
@gMatches = Match.where(g_id: self.id, round: matchRound) @gMatches = Match.where(g_id: self.id, round: matchRound)
@@ -29,12 +29,12 @@ class Wrestler < ActiveRecord::Base
end end
end end
def matches_all def allMatches(matches)
@gMatches = Match.where(g_id: self.id) @matches = matches.select{|m| m.w1 == self.id || m.w2 == self.id}
@rMatches = Match.where(r_id: self.id) return @matches
return @gMatches + @rMatches
end end
def seasonWinPercentage def seasonWinPercentage
@win = self.season_win.to_f @win = self.season_win.to_f
@loss = self.season_loss.to_f @loss = self.season_loss.to_f
@@ -48,7 +48,6 @@ class Wrestler < ActiveRecord::Base
elsif self.season_win == nil or self.season_loss == nil elsif self.season_win == nil or self.season_loss == nil
return 0 return 0
end end
end end
end end