performance tweaks for rails 4.1

This commit is contained in:
r888888888
2014-04-24 22:18:14 -07:00
parent a89c57cee0
commit aab03422bc
16 changed files with 22 additions and 16 deletions

View File

@@ -13,7 +13,7 @@ class AdvertisementsController < ApplicationController
end
def index
@advertisements = Advertisement.order("id desc").all
@advertisements = Advertisement.order("id desc")
@start_date = 1.month.ago.to_date
@end_date = Date.today
end

View File

@@ -79,7 +79,7 @@ private
def index_by_post
@posts = Post.where("last_comment_bumped_at IS NOT NULL").tag_match(params[:tags]).reorder("last_comment_bumped_at DESC").paginate(params[:page], :limit => 5, :search_count => params[:search])
@posts.all
@posts.each # hack to force rails to eager load
respond_with(@posts) do |format|
format.html {render :action => "index_by_post"}
format.xml do

View File

@@ -31,7 +31,7 @@ class ForumTopicsController < ApplicationController
def show
@forum_topic = ForumTopic.find(params[:id])
@forum_posts = ForumPost.search(:topic_id => @forum_topic.id).order("forum_posts.id").paginate(params[:page])
@forum_posts.all
@forum_posts.each # hack to force rails to eager load
respond_with(@forum_topic)
unless CurrentUser.user.is_anonymous?
session[:read_forum_topics] = @forum_topic.mark_as_read(read_forum_topic_ids)

View File

@@ -7,7 +7,7 @@ module Moderator
def show
::Post.without_timeout do
@posts = ::Post.order("posts.id asc").pending_or_flagged.available_for_moderation(params[:hidden]).search(:tag_match => "#{params[:query]} status:any").paginate(params[:page], :limit => 100)
@posts.all # cache the data
@posts.each # hack to force rails to eager load
end
respond_with(@posts)
end

View File

@@ -22,7 +22,9 @@ class PoolElementsController < ApplicationController
end
def all_select
@pools = Pool.undeleted.where("is_active = true").order("name").select("id, name").all
@pools = Pool.undeleted.where("is_active = true").order("name").select("id, name")
@pools.each # hack to force rails to eager load
@pools
end
private