From a3cf41918b1f18ee9b36c6cc1a44ee104ed5d9cb Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 23 Dec 2015 15:29:32 +0000 Subject: [PATCH] Cache other pages that users will frequent --- app/models/match.rb | 2 + app/models/wrestler.rb | 4 +- app/views/schools/show.html.erb | 152 +++++++++++++++--------------- app/views/wrestlers/show.html.erb | 78 +++++++-------- 4 files changed, 121 insertions(+), 115 deletions(-) diff --git a/app/models/match.rb b/app/models/match.rb index 70ce5f8..4bf1158 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -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 diff --git a/app/models/wrestler.rb b/app/models/wrestler.rb index d957a18..dd78e58 100644 --- a/app/models/wrestler.rb +++ b/app/models/wrestler.rb @@ -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" diff --git a/app/views/schools/show.html.erb b/app/views/schools/show.html.erb index 8e75732..ccb09a8 100644 --- a/app/views/schools/show.html.erb +++ b/app/views/schools/show.html.erb @@ -1,76 +1,78 @@ -

<%= notice %>

-<%= 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 %> -
-
-

- Name: - <%= @school.name %> -

- -

- Score: - <%= @school.score %> -

- -

- Tournament: - <%= Tournament.find(@school.tournament_id).name %> -

- - - - - -
-<% if tournament_permissions(@school.tournament) %> - <%= link_to "New #{@school.name} Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"btn btn-success"%> -<% end %> -
-
- - - - - - - - - - - - - - - - - - <% @wrestlers.order("weight_id asc").each do |wrestler| %> - <% if wrestler.school_id == @school.id %> - - - - - - - - - - - +<% cache ["schools", @school] do %> +

<%= notice %>

+ <%= 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 %> +
+
+

+ Name: + <%= @school.name %> +

+ +

+ Score: + <%= @school.score %> +

+ +

+ Tournament: + <%= Tournament.find(@school.tournament_id).name %> +

+ + + + + +
+ <% if tournament_permissions(@school.tournament) %> + <%= link_to "New #{@school.name} Wrestler" , "/wrestlers/new?school=#{@school.id}", :class=>"btn btn-success"%> + <% end %> +
+
+ +
NameWeightSeedRecordSeed CriteriaTeam Points ScoredExtra?Next Bout/MatActions
<%= wrestler.name %><%= Weight.find(wrestler.weight_id).max %> - <%= wrestler.original_seed %> - <%= wrestler.season_win %>-<%= wrestler.season_loss %><%= wrestler.criteria %> Win <%= wrestler.seasonWinPercentage %>%<%= wrestler.totalTeamPoints - wrestler.totalDeductedPoints %><% if wrestler.extra? == true %> - Yes - <% end %><%= wrestler.nextMatchBoutNumber %> <%= wrestler.nextMatchMatName %> - <%= 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 %> -
+ + + + + + + + + + + + + + + + <% @wrestlers.order("weight_id asc").each do |wrestler| %> + <% if wrestler.school_id == @school.id %> + + + + + + + + + + + + <% end %> <% end %> - <% end %> - -
NameWeightSeedRecordSeed CriteriaTeam Points ScoredExtra?Next Bout/MatActions
<%= wrestler.name %><%= Weight.find(wrestler.weight_id).max %> + <%= wrestler.original_seed %> + <%= wrestler.season_win %>-<%= wrestler.season_loss %><%= wrestler.criteria %> Win <%= wrestler.seasonWinPercentage %>%<%= wrestler.totalTeamPoints - wrestler.totalDeductedPoints %><% if wrestler.extra? == true %> + Yes + <% end %><%= wrestler.nextMatchBoutNumber %> <%= wrestler.nextMatchMatName %> + <%= 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 %> +
+ + +<% end %> diff --git a/app/views/wrestlers/show.html.erb b/app/views/wrestlers/show.html.erb index 825bf65..9f5f3e8 100644 --- a/app/views/wrestlers/show.html.erb +++ b/app/views/wrestlers/show.html.erb @@ -1,38 +1,40 @@ -

<%= notice %>

- -<%= 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 %> -
-
-

- Name: - <%= @wrestler.name %> -

- -

- School: - <%= @wrestler.school.name %> -

- -

- Weight: - <%= @wrestler.weight.max %> -

- -

- Team Points Scored: - <%= @wrestler.totalTeamPoints %> -

- -
-
-

Matches

-
-<% @wrestler.allMatches.each do |m| %> -
Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= @wrestler.resultByBout(m.bout_number) %>
-<% end %> -<% @wrestler.deductedPoints.each do |w| %> -
Deducted points: <%= w.points %>
-<% end %> +<% cache ["wrestlers", @wrestler] do %> +

<%= notice %>

+ + <%= 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 %> +
+
+

+ Name: + <%= @wrestler.name %> +

+ +

+ School: + <%= @wrestler.school.name %> +

+ +

+ Weight: + <%= @wrestler.weight.max %> +

+ +

+ Team Points Scored: + <%= @wrestler.totalTeamPoints %> +

+ +
+
+

Matches

+
+ <% @wrestler.allMatches.each do |m| %> +
Bout: <%= m.bout_number %> <%= m.bracket_position %> <%= m.wrestler1.name %> vs. <%= m.wrestler2.name %> <%= @wrestler.resultByBout(m.bout_number) %>
+ <% end %> + <% @wrestler.deductedPoints.each do |w| %> +
Deducted points: <%= w.points %>
+ <% end %> +<% end %> \ No newline at end of file