mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Cache other pages that users will frequent
This commit is contained in:
@@ -6,6 +6,8 @@ class Match < ActiveRecord::Base
|
||||
|
||||
after_save do
|
||||
if self.finished == 1 && self.winner_id != nil
|
||||
wrestler1.touch
|
||||
wrestler2.touch
|
||||
advance_wrestlers
|
||||
calcSchoolPoints
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Wrestler < ActiveRecord::Base
|
||||
belongs_to :school
|
||||
belongs_to :weight
|
||||
belongs_to :school, touch: true
|
||||
belongs_to :weight, touch: true
|
||||
has_one :tournament, through: :weight
|
||||
has_many :matches, through: :weight
|
||||
has_many :deductedPoints, class_name: "Teampointadjust"
|
||||
|
||||
@@ -1,76 +1,78 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}",:class=>"btn btn-default" %>
|
||||
<% if tournament_permissions(@school.tournament) %>
|
||||
| <%= link_to "Edit #{@school.name}", edit_school_path(@school),:class=>"btn btn-primary" %>
|
||||
<% end %>
|
||||
<br>
|
||||
<br>
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= @school.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Score:</strong>
|
||||
<%= @school.score %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Tournament:</strong>
|
||||
<%= Tournament.find(@school.tournament_id).name %>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<% if tournament_permissions(@school.tournament) %>
|
||||
<%= link_to "New #{@school.name} Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"btn btn-success"%>
|
||||
<% end %>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Weight</th>
|
||||
<th>Seed</th>
|
||||
<th>Record</th>
|
||||
<th>Seed Criteria</th>
|
||||
<th>Team Points Scored</th>
|
||||
<th>Extra?</th>
|
||||
<th>Next Bout/Mat</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @wrestlers.order("weight_id asc").each do |wrestler| %>
|
||||
<% if wrestler.school_id == @school.id %>
|
||||
<tr>
|
||||
<td><%= wrestler.name %></td>
|
||||
<td><%= Weight.find(wrestler.weight_id).max %></td>
|
||||
<td>
|
||||
<%= wrestler.original_seed %>
|
||||
</td>
|
||||
<td><%= wrestler.season_win %>-<%= wrestler.season_loss %></td>
|
||||
<td><%= wrestler.criteria %> Win <%= wrestler.seasonWinPercentage %>%</td>
|
||||
<td><%= wrestler.totalTeamPoints - wrestler.totalDeductedPoints %></td>
|
||||
<td><% if wrestler.extra? == true %>
|
||||
Yes
|
||||
<% end %></td>
|
||||
<td><%= wrestler.nextMatchBoutNumber %> <%= wrestler.nextMatchMatName %></td>
|
||||
<td>
|
||||
<%= link_to 'Show', wrestler , :class=>"btn btn-default" %>
|
||||
<% if tournament_permissions(@school.tournament) %>
|
||||
<%= link_to 'Edit', edit_wrestler_path(wrestler),:class=>"btn btn-primary" %>
|
||||
<%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% cache ["schools", @school] do %>
|
||||
<p id="notice"><%= notice %></p>
|
||||
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}",:class=>"btn btn-default" %>
|
||||
<% if tournament_permissions(@school.tournament) %>
|
||||
| <%= link_to "Edit #{@school.name}", edit_school_path(@school),:class=>"btn btn-primary" %>
|
||||
<% end %>
|
||||
<br>
|
||||
<br>
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= @school.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Score:</strong>
|
||||
<%= @school.score %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Tournament:</strong>
|
||||
<%= Tournament.find(@school.tournament_id).name %>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<% if tournament_permissions(@school.tournament) %>
|
||||
<%= link_to "New #{@school.name} Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"btn btn-success"%>
|
||||
<% end %>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Weight</th>
|
||||
<th>Seed</th>
|
||||
<th>Record</th>
|
||||
<th>Seed Criteria</th>
|
||||
<th>Team Points Scored</th>
|
||||
<th>Extra?</th>
|
||||
<th>Next Bout/Mat</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @wrestlers.order("weight_id asc").each do |wrestler| %>
|
||||
<% if wrestler.school_id == @school.id %>
|
||||
<tr>
|
||||
<td><%= wrestler.name %></td>
|
||||
<td><%= Weight.find(wrestler.weight_id).max %></td>
|
||||
<td>
|
||||
<%= wrestler.original_seed %>
|
||||
</td>
|
||||
<td><%= wrestler.season_win %>-<%= wrestler.season_loss %></td>
|
||||
<td><%= wrestler.criteria %> Win <%= wrestler.seasonWinPercentage %>%</td>
|
||||
<td><%= wrestler.totalTeamPoints - wrestler.totalDeductedPoints %></td>
|
||||
<td><% if wrestler.extra? == true %>
|
||||
Yes
|
||||
<% end %></td>
|
||||
<td><%= wrestler.nextMatchBoutNumber %> <%= wrestler.nextMatchMatName %></td>
|
||||
<td>
|
||||
<%= link_to 'Show', wrestler , :class=>"btn btn-default" %>
|
||||
<% if tournament_permissions(@school.tournament) %>
|
||||
<%= link_to 'Edit', edit_wrestler_path(wrestler),:class=>"btn btn-primary" %>
|
||||
<%= link_to 'Destroy', wrestler, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
@@ -1,38 +1,40 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %>
|
||||
<% if tournament_permissions(@wrestler.tournament) %>
|
||||
| <%= link_to "Edit #{@wrestler.name}", edit_wrestler_path(@wrestler), :class=>"btn btn-primary" %>
|
||||
<% end %>
|
||||
<br>
|
||||
<br>
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= @wrestler.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>School:</strong>
|
||||
<%= @wrestler.school.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Weight:</strong>
|
||||
<%= @wrestler.weight.max %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Team Points Scored:</strong>
|
||||
<%= @wrestler.totalTeamPoints %>
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<h4>Matches</h4>
|
||||
<br>
|
||||
<% @wrestler.allMatches.each do |m| %>
|
||||
<div> Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= @wrestler.resultByBout(m.bout_number) %></div>
|
||||
<% end %>
|
||||
<% @wrestler.deductedPoints.each do |w| %>
|
||||
<div> Deducted points: <%= w.points %></div>
|
||||
<% end %>
|
||||
<% cache ["wrestlers", @wrestler] do %>
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<%= link_to "Back to #{@school.name}", "/schools/#{@school.id}", :class=>"btn btn-default" %>
|
||||
<% if tournament_permissions(@wrestler.tournament) %>
|
||||
| <%= link_to "Edit #{@wrestler.name}", edit_wrestler_path(@wrestler), :class=>"btn btn-primary" %>
|
||||
<% end %>
|
||||
<br>
|
||||
<br>
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= @wrestler.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>School:</strong>
|
||||
<%= @wrestler.school.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Weight:</strong>
|
||||
<%= @wrestler.weight.max %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Team Points Scored:</strong>
|
||||
<%= @wrestler.totalTeamPoints %>
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<h4>Matches</h4>
|
||||
<br>
|
||||
<% @wrestler.allMatches.each do |m| %>
|
||||
<div> Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= @wrestler.resultByBout(m.bout_number) %></div>
|
||||
<% end %>
|
||||
<% @wrestler.deductedPoints.each do |w| %>
|
||||
<div> Deducted points: <%= w.points %></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user