mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-26 07:56:57 +00:00
Revert "Added memcached and set up cached items for up_matches page"
This reverts commit 983cc9c667.
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -45,7 +45,6 @@ gem 'spring', :group => :development
|
|||||||
gem 'passenger'
|
gem 'passenger'
|
||||||
gem 'therubyracer'
|
gem 'therubyracer'
|
||||||
gem 'newrelic_rpm'
|
gem 'newrelic_rpm'
|
||||||
gem 'dalli'
|
|
||||||
end
|
end
|
||||||
#Other
|
#Other
|
||||||
gem 'devise'
|
gem 'devise'
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ GEM
|
|||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.9.1.1)
|
coffee-script-source (1.9.1.1)
|
||||||
concurrent-ruby (1.0.0)
|
concurrent-ruby (1.0.0)
|
||||||
dalli (2.7.5)
|
|
||||||
devise (3.4.1)
|
devise (3.4.1)
|
||||||
bcrypt (~> 3.0)
|
bcrypt (~> 3.0)
|
||||||
orm_adapter (~> 0.1)
|
orm_adapter (~> 0.1)
|
||||||
@@ -161,7 +160,6 @@ PLATFORMS
|
|||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
cancancan
|
cancancan
|
||||||
coffee-rails (~> 4.0.0)
|
coffee-rails (~> 4.0.0)
|
||||||
dalli
|
|
||||||
devise
|
devise
|
||||||
jbuilder (~> 2.0)
|
jbuilder (~> 2.0)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ class TournamentsController < ApplicationController
|
|||||||
|
|
||||||
|
|
||||||
def up_matches
|
def up_matches
|
||||||
@matches = @tournament.cached_matches.select{|m| m.mat_id == nil}.sort_by{|m| m.bout_number}
|
@matches = @tournament.matches.where(mat_id: nil).order('bout_number ASC').limit(10).includes(:wrestlers)
|
||||||
@mats = @tournament.mats
|
@mats = @tournament.mats.includes(:matches)
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@@ -144,7 +144,7 @@ class TournamentsController < ApplicationController
|
|||||||
|
|
||||||
def check_for_matches
|
def check_for_matches
|
||||||
if @tournament
|
if @tournament
|
||||||
if @tournament.cached_matches.empty?
|
if @tournament.matches.empty?
|
||||||
redirect_to "/tournaments/#{@tournament.id}/no_matches"
|
redirect_to "/tournaments/#{@tournament.id}/no_matches"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,15 +18,6 @@ class Mat < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def cached_matches
|
|
||||||
cache_timestamp = self.updated_at
|
|
||||||
cache_key = "matMatches|#{id}|#{cache_timestamp}"
|
|
||||||
|
|
||||||
Rails.cache.fetch(cache_key, expires_in: 10.minutes) do
|
|
||||||
self.matches.includes(:wrestlers)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def assignNextMatch
|
def assignNextMatch
|
||||||
t_matches = tournament.matches.select{|m| m.mat_id == nil}
|
t_matches = tournament.matches.select{|m| m.mat_id == nil}
|
||||||
if t_matches.size > 0
|
if t_matches.size > 0
|
||||||
@@ -37,7 +28,7 @@ class Mat < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def unfinishedMatches
|
def unfinishedMatches
|
||||||
cached_matches.select{|m| m.finished == nil}.sort_by{|m| m.bout_number}
|
matches.select{|m| m.finished == nil}.sort_by{|m| m.bout_number}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class Match < ActiveRecord::Base
|
class Match < ActiveRecord::Base
|
||||||
belongs_to :tournament, touch: true
|
belongs_to :tournament
|
||||||
belongs_to :weight, touch: true
|
belongs_to :weight
|
||||||
belongs_to :mat, touch: true
|
belongs_to :mat
|
||||||
has_many :wrestlers, :through => :weight
|
has_many :wrestlers, :through => :weight
|
||||||
|
|
||||||
after_save do
|
after_save do
|
||||||
|
|||||||
@@ -9,14 +9,7 @@ class Tournament < ActiveRecord::Base
|
|||||||
has_many :wrestlers, through: :weights
|
has_many :wrestlers, through: :weights
|
||||||
has_many :matches, dependent: :destroy
|
has_many :matches, dependent: :destroy
|
||||||
|
|
||||||
def cached_matches
|
|
||||||
cache_timestamp = self.updated_at
|
|
||||||
cache_key = "tournamentMatches|#{id}|#{cache_timestamp}"
|
|
||||||
|
|
||||||
Rails.cache.fetch(cache_key, expires_in: 10.minutes) do
|
|
||||||
self.matches.includes(:wrestlers)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def tournament_types
|
def tournament_types
|
||||||
["Pool to bracket"]
|
["Pool to bracket"]
|
||||||
|
|||||||
@@ -54,14 +54,6 @@ Wrestling::Application.configure do
|
|||||||
|
|
||||||
# Use a different cache store in production.
|
# Use a different cache store in production.
|
||||||
# config.cache_store = :mem_cache_store
|
# 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.
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
||||||
# config.action_controller.asset_host = "http://assets.example.com"
|
# config.action_controller.asset_host = "http://assets.example.com"
|
||||||
|
|||||||
Reference in New Issue
Block a user