1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Page caching set up

This commit is contained in:
2015-12-23 14:11:20 +00:00
parent be1df55e39
commit db876809ef
6 changed files with 109 additions and 94 deletions

View File

@@ -42,9 +42,10 @@ gem 'spring', :group => :development
group :production do
gem 'rails_12factor'
gem 'mysql2'
gem 'passenger'
gem 'therubyracer'
gem 'passenger'
gem 'therubyracer'
gem 'newrelic_rpm'
gem 'dalli'
end
#Other
gem 'devise'

View File

@@ -48,6 +48,7 @@ GEM
execjs
coffee-script-source (1.9.1.1)
concurrent-ruby (1.0.0)
dalli (2.7.5)
devise (3.4.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
@@ -160,6 +161,7 @@ PLATFORMS
DEPENDENCIES
cancancan
coffee-rails (~> 4.0.0)
dalli
devise
jbuilder (~> 2.0)
jquery-rails

View File

@@ -1,7 +1,7 @@
class Match < ActiveRecord::Base
belongs_to :tournament
belongs_to :weight
belongs_to :mat
belongs_to :tournament, touch: true
belongs_to :weight, touch: true
belongs_to :mat, touch: true
has_many :wrestlers, :through => :weight
after_save do

View File

@@ -1,23 +1,25 @@
</br>
</br>
</br>
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>
<br>
<br>
<h1><%= @weight.max %> lbs Bracket</h1>
<%= render 'pool' %>
<% if @bracketType == "twoPoolsToFinal" %>
<%= render 'twoPoolFinalBracket' %>
<% end %>
<% if @bracketType == "twoPoolsToSemi" %>
<%= render 'twoPoolSemiBracket' %>
<% end %>
<% if @bracketType == "fourPoolsToQuarter" %>
<%= render 'fourPoolQuarterBracket' %>
<% end %>
<% if @bracketType == "fourPoolsToSemi" %>
<%= render 'fourPoolSemiBracket' %>
<% end %>
<% cache ["brackets", @weight] do %>
</br>
</br>
</br>
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>
<br>
<br>
<h1><%= @weight.max %> lbs Bracket</h1>
<%= render 'pool' %>
<% if @bracketType == "twoPoolsToFinal" %>
<%= render 'twoPoolFinalBracket' %>
<% end %>
<% if @bracketType == "twoPoolsToSemi" %>
<%= render 'twoPoolSemiBracket' %>
<% end %>
<% if @bracketType == "fourPoolsToQuarter" %>
<%= render 'fourPoolQuarterBracket' %>
<% end %>
<% if @bracketType == "fourPoolsToSemi" %>
<%= render 'fourPoolSemiBracket' %>
<% end %>
<% end %>

View File

@@ -1,70 +1,72 @@
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default"%>
<script>
$(document).ready(function() {
$('#matchList').dataTable();
} );
</script>
<script>
setTimeout("location.reload(true);",30000);
</script>
<br>
<br>
<h5 style="color:red">This page reloads every 30s</h5>
<br>
<br>
<h3>Upcoming Matches</h3>
<br>
<br>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Mat</th>
<th>On Mat</th>
<th>On Deck</th>
<th>In The Hole</th>
<th>Warm Up</th>
</tr>
</thead>
<tbody>
<% @mats.each.map do |m| %>
<% cache ["up_matches", @tournament] do %>
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default"%>
<script>
$(document).ready(function() {
$('#matchList').dataTable();
} );
</script>
<script>
setTimeout("location.reload(true);",30000);
</script>
<br>
<br>
<h5 style="color:red">This page reloads every 30s</h5>
<br>
<br>
<h3>Upcoming Matches</h3>
<br>
<br>
<table class="table table-striped table-bordered">
<thead>
<tr>
<td><%= m.name %></td>
<td><% if m.unfinishedMatches.first %><%=m.unfinishedMatches.first.bout_number%><br><%= m.unfinishedMatches.first.w1_name %> vs. <%= m.unfinishedMatches.first.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.second %><%=m.unfinishedMatches.second.bout_number%><br><%= m.unfinishedMatches.second.w1_name %> vs. <%= m.unfinishedMatches.second.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.third %><%=m.unfinishedMatches.third.bout_number%><br><%= m.unfinishedMatches.third.w1_name %> vs. <%= m.unfinishedMatches.third.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.fourth %><%=m.unfinishedMatches.fourth.bout_number%><br><%= m.unfinishedMatches.fourth.w1_name %> vs. <%= m.unfinishedMatches.fourth.w2_name %><% end %></td>
<th>Mat</th>
<th>On Mat</th>
<th>On Deck</th>
<th>In The Hole</th>
<th>Warm Up</th>
</tr>
<% end %>
</tbody>
</table>
<br>
<br>
<h3>Matches not assigned</h3>
<br>
<br>
<table class="display compact cell-border" id="matchList">
<thead>
<tr>
<th>Round</th>
<th>Bout Number</th>
<th>Weight Class</th>
<th>Matchup</th>
</tr>
</thead>
<tbody>
<% if @matches.size > 0 %>
<% @matches.each.map do |m| %>
</thead>
<tbody>
<% @mats.each.map do |m| %>
<tr>
<td><%= m.name %></td>
<td><% if m.unfinishedMatches.first %><%=m.unfinishedMatches.first.bout_number%><br><%= m.unfinishedMatches.first.w1_name %> vs. <%= m.unfinishedMatches.first.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.second %><%=m.unfinishedMatches.second.bout_number%><br><%= m.unfinishedMatches.second.w1_name %> vs. <%= m.unfinishedMatches.second.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.third %><%=m.unfinishedMatches.third.bout_number%><br><%= m.unfinishedMatches.third.w1_name %> vs. <%= m.unfinishedMatches.third.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.fourth %><%=m.unfinishedMatches.fourth.bout_number%><br><%= m.unfinishedMatches.fourth.w1_name %> vs. <%= m.unfinishedMatches.fourth.w2_name %><% end %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<br>
<h3>Matches not assigned</h3>
<br>
<br>
<table class="display compact cell-border" id="matchList">
<thead>
<tr>
<td>Round <%= m.round %></td>
<td><%= m.bout_number %></td>
<td><%= m.weight_max %> lbs</td>
<td><%= m.w1_name %> vs. <%= m.w2_name %></td>
<th>Round</th>
<th>Bout Number</th>
<th>Weight Class</th>
<th>Matchup</th>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<br>
</thead>
<tbody>
<% if @matches.size > 0 %>
<% @matches.each.map do |m| %>
<tr>
<td>Round <%= m.round %></td>
<td><%= m.bout_number %></td>
<td><%= m.weight_max %> lbs</td>
<td><%= m.w1_name %> vs. <%= m.w2_name %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<br>
<% end %>

View File

@@ -54,6 +54,14 @@ Wrestling::Application.configure do
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
config.cache_store = :dalli_store,
(ENV["MEMCACHIER_SERVERS"] || "").split(","),
{:username => ENV["MEMCACHIER_USERNAME"],
:password => ENV["MEMCACHIER_PASSWORD"],
:failover => true,
:socket_timeout => 1.5,
:socket_failure_delay => 0.2
}
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"