mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-05 06:07:20 +00:00
Calculated win percentage
This commit is contained in:
@@ -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
|
attr_accessor :matches_all, :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,4 +29,15 @@ class Wrestler < ActiveRecord::Base
|
|||||||
return @gMatches + @rMatches
|
return @gMatches + @rMatches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def seasonWinPercentage
|
||||||
|
if self.season_win > 0 and self.season_loss > 0
|
||||||
|
@percentage = self.season_win / (self.season_win + self.season_loss)
|
||||||
|
return @percentage
|
||||||
|
elsif self.season_win == 0
|
||||||
|
return 0
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
<td><%= Weight.find(wrestler.weight_id).max %></td>
|
<td><%= Weight.find(wrestler.weight_id).max %></td>
|
||||||
<td><%= wrestler.original_seed %></td>
|
<td><%= wrestler.original_seed %></td>
|
||||||
<td><%= wrestler.season_win %>-<%= wrestler.season_loss %></td>
|
<td><%= wrestler.season_win %>-<%= wrestler.season_loss %></td>
|
||||||
<td><%= wrestler.criteria %></td>
|
<td><%= wrestler.criteria %> Win <%= wrestler.seasonWinPercentage %>%</td>
|
||||||
<td><% if wrestler.extra? == true %>
|
<td><% if wrestler.extra? == true %>
|
||||||
Yes
|
Yes
|
||||||
<% end %></td>
|
<% end %></td>
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
</br>
|
||||||
|
</br>
|
||||||
|
</br>
|
||||||
|
|
||||||
<%= link_to "Back to #{@tournament.name} weights", "/static_pages/weights?tournament=#{@tournament.id}" %>
|
<%= link_to "Back to #{@tournament.name} weights", "/static_pages/weights?tournament=#{@tournament.id}" %>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
<td><%= School.find(wrestler.school_id).name %></td>
|
<td><%= School.find(wrestler.school_id).name %></td>
|
||||||
<td><%= wrestler.original_seed %></td>
|
<td><%= wrestler.original_seed %></td>
|
||||||
<td><%= wrestler.season_win %>-<%= wrestler.season_loss %></td>
|
<td><%= wrestler.season_win %>-<%= wrestler.season_loss %></td>
|
||||||
<td><%= wrestler.criteria %></td>
|
<td><%= wrestler.criteria %> Win <%= wrestler.seasonWinPercentage %>%</td>
|
||||||
<td><% if wrestler.extra? == true %>
|
<td><% if wrestler.extra? == true %>
|
||||||
Yes
|
Yes
|
||||||
<% end %></td>
|
<% end %></td>
|
||||||
|
|||||||
Reference in New Issue
Block a user