mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-06 14:36:59 +00:00
Ensuring good caching for the most popular pages. Added tests.
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
<% @final_match.each do |match| %>
|
||||
<div class="round">
|
||||
<div class="game">
|
||||
<div class="game-top "><%= match.w1_bracket_name.html_safe %> <span></span></div>
|
||||
<% if params[:print] %>
|
||||
<div class="bout-number"><p><%= match.bout_number %> <%= match.bracket_score_string %></p><p><%= @winner_place %> Place Winner</p></div>
|
||||
<% else %>
|
||||
<div class="bout-number"><p><%= link_to match.bout_number, spectate_match_path(match) %> <%= match.bracket_score_string %></p><p><%= @winner_place %> Place Winner</p></div>
|
||||
<% end %>
|
||||
<div class="game-bottom "><%= match.w2_bracket_name.html_safe %><span></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<% cache ["bracket_final_match", match, match.wrestler1, match.wrestler2, @winner_place, params[:print].to_s] do %>
|
||||
<div class="round">
|
||||
<div class="game">
|
||||
<div class="game-top "><%= match.w1_bracket_name.html_safe %> <span></span></div>
|
||||
<% if params[:print] %>
|
||||
<div class="bout-number"><p><%= match.bout_number %> <%= match.bracket_score_string %></p><p><%= @winner_place %> Place Winner</p></div>
|
||||
<% else %>
|
||||
<div class="bout-number"><p><%= link_to match.bout_number, spectate_match_path(match) %> <%= match.bracket_score_string %></p><p><%= @winner_place %> Place Winner</p></div>
|
||||
<% end %>
|
||||
<div class="game-bottom "><%= match.w2_bracket_name.html_safe %><span></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
<div class="round">
|
||||
<% @round_matches.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<div class="game">
|
||||
<div class="game-top "><%= match.w1_bracket_name.html_safe %> <span></span></div>
|
||||
<% if params[:print] %>
|
||||
<div class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </div>
|
||||
<% else %>
|
||||
<div class="bout-number"><%= link_to match.bout_number, spectate_match_path(match) %> <%= match.bracket_score_string %> </div>
|
||||
<% end %>
|
||||
<div class="bout-number">Round <%= match.round %></div>
|
||||
<div class="bout-number"><%= match.bracket_position %></div>
|
||||
<div class="game-bottom "><%= match.w2_bracket_name.html_safe %><span></span></div>
|
||||
</div>
|
||||
<% cache ["bracket_round_match", match, match.wrestler1, match.wrestler2, params[:print].to_s] do %>
|
||||
<div class="game">
|
||||
<div class="game-top "><%= match.w1_bracket_name.html_safe %> <span></span></div>
|
||||
<% if params[:print] %>
|
||||
<div class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </div>
|
||||
<% else %>
|
||||
<div class="bout-number"><%= link_to match.bout_number, spectate_match_path(match) %> <%= match.bracket_score_string %> </div>
|
||||
<% end %>
|
||||
<div class="bout-number">Round <%= match.round %></div>
|
||||
<div class="bout-number"><%= match.bracket_position %></div>
|
||||
<div class="game-bottom "><%= match.w2_bracket_name.html_safe %><span></span></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
6
app/views/tournaments/_team_score_row.html.erb
Normal file
6
app/views/tournaments/_team_score_row.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<% cache ["team_score_row", school, rank] do %>
|
||||
<tr>
|
||||
<td><%= rank %>. <%= school.name %> (<%= school.abbreviation %>)</td>
|
||||
<td><%= school.page_score_string %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
@@ -31,14 +31,7 @@
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% (local_assigns[:matches] || tournament.up_matches_unassigned_matches).each do |m| %>
|
||||
<tr>
|
||||
<td>Round <%= m.round %></td>
|
||||
<td><%= m.bout_number %></td>
|
||||
<td><%= m.weight_max %></td>
|
||||
<td><%= m.w1_bracket_name %> vs. <%= m.w2_bracket_name %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<%= render partial: "tournaments/up_matches_unassigned_row", collection: (local_assigns[:matches] || tournament.up_matches_unassigned_matches), as: :match %>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<% queue1_match, queue2_match, queue3_match, queue4_match = mat.queue_matches %>
|
||||
<% cache ["up_matches_mat_row", mat, mat.queue1, mat.queue2, mat.queue3, mat.queue4] do %>
|
||||
<% queue_match_dependencies = [queue1_match, queue2_match, queue3_match, queue4_match].compact.flat_map { |match| [match, match.wrestler1, match.wrestler2] } %>
|
||||
<% cache ["up_matches_mat_row", mat, *queue_match_dependencies] do %>
|
||||
<tr>
|
||||
<td><%= mat.name %></td>
|
||||
<td>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<% cache ["up_matches_unassigned_row", match, match.wrestler1, match.wrestler2] do %>
|
||||
<tr>
|
||||
<td>Round <%= match.round %></td>
|
||||
<td><%= match.bout_number %></td>
|
||||
<td><%= match.weight_max %></td>
|
||||
<td><%= match.w1_bracket_name %> vs. <%= match.w2_bracket_name %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
@@ -1,8 +1,8 @@
|
||||
<% cache ["#{@weight.id}_bracket", @weight] do %>
|
||||
<% cache ["#{@weight.id}_bracket", @weight, params[:print].to_s] do %>
|
||||
<%= render 'bracket_partial' %>
|
||||
<% end %>
|
||||
<% if @tournament.tournament_type == "Pool to bracket" %>
|
||||
<%= render 'pool_bracket_director_actions' %>
|
||||
<% elsif @tournament.tournament_type.include? "Modified 16 Man Double Elimination" or @tournament.tournament_type.include? "Regular Double Elimination" %>
|
||||
<%= render 'bracket_director_actions' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
<% cache ["#{@tournament.id}_team_scores", @tournament] do %>
|
||||
|
||||
<% team_scores_last_updated = @schools.map(&:updated_at).compact.max&.utc&.to_fs(:nsec) %>
|
||||
<% cache ["team_scores", @tournament.id, @schools.size, team_scores_last_updated] do %>
|
||||
<table class="pagebreak table table-striped table-bordered">
|
||||
<h3>Team Scores</h3>
|
||||
<thead>
|
||||
@@ -11,12 +10,9 @@
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @schools.each do |school| %>
|
||||
<tr>
|
||||
<td><%= @schools.index(school) + 1 %>. <%= school.name %> (<%= school.abbreviation %>)</td>
|
||||
<td><%= school.page_score_string %></td>
|
||||
</tr>
|
||||
<% @schools.each_with_index do |school, index| %>
|
||||
<%= render "tournaments/team_score_row", school: school, rank: index + 1 %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user