forked from e621ng/e621ng
performance tweaks for rails 4.1
This commit is contained in:
parent
a89c57cee0
commit
aab03422bc
1
Gemfile
1
Gemfile
@ -51,5 +51,6 @@ end
|
||||
|
||||
group :development do
|
||||
gem 'ruby-prof'
|
||||
gem 'sql-logging'
|
||||
end
|
||||
|
||||
|
@ -183,6 +183,8 @@ GEM
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (~> 2.8)
|
||||
sql-logging (3.0.8)
|
||||
rails (> 3.0.0)
|
||||
statistics2 (0.54)
|
||||
term-ansicolor (1.3.0)
|
||||
tins (~> 1.0)
|
||||
@ -253,6 +255,7 @@ DEPENDENCIES
|
||||
shoulda
|
||||
simple_form
|
||||
simplecov
|
||||
sql-logging
|
||||
statistics2
|
||||
term-ansicolor
|
||||
therubyracer
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -7,7 +7,7 @@ module PostSets
|
||||
def posts
|
||||
@posts ||= begin
|
||||
temp = ::Post.tag_match("#{tag_string} favcount:>3").paginate(page, :search_count => nil, :limit => 5)
|
||||
temp.all
|
||||
temp.each # hack to force rails to eager load
|
||||
temp
|
||||
end
|
||||
end
|
||||
|
@ -73,7 +73,7 @@ module PostSets
|
||||
else
|
||||
temp = ::Post.tag_match(tag_string).paginate(page, :count => ::Post.fast_count(tag_string), :limit => per_page)
|
||||
end
|
||||
temp.all
|
||||
temp.each # hack to force rails to eager load
|
||||
temp
|
||||
end
|
||||
end
|
||||
|
@ -4,7 +4,7 @@ require 'mail'
|
||||
|
||||
class UploadErrorChecker
|
||||
def check!
|
||||
uploads = Upload.where("status like 'error%' and status not like 'error: RuntimeError - duplicate%' and created_at >= ?", 1.hour.ago).all
|
||||
uploads = Upload.where("status like 'error%' and status not like 'error: RuntimeError - duplicate%' and created_at >= ?", 1.hour.ago)
|
||||
if uploads.size > 5
|
||||
mail = Mail.new do
|
||||
from "webmaster@danbooru.donmai.us"
|
||||
|
@ -66,7 +66,7 @@ class PostVersion < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def sequence_for_post
|
||||
versions = PostVersion.where(:post_id => post_id).order("updated_at desc, id desc").all
|
||||
versions = PostVersion.where(:post_id => post_id).order("updated_at desc, id desc")
|
||||
diffs = []
|
||||
versions.each_index do |i|
|
||||
if i < versions.size - 1
|
||||
|
@ -607,7 +607,7 @@ class Tag < ActiveRecord::Base
|
||||
search_for = "%" + query.to_escaped_for_sql_like + "%"
|
||||
end
|
||||
|
||||
Tag.where(["name LIKE ? ESCAPE E'\\\\' AND post_count > 0 AND name <> ?", search_for, query]).all(:order => "post_count DESC", :limit => 6, :select => "name").map(&:name).sort
|
||||
Tag.where(["name LIKE ? ESCAPE E'\\\\' AND post_count > 0 AND name <> ?", search_for, query]).order("post_count DESC").limit(6).select("name").map(&:name).sort
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,7 +29,7 @@ class TagImplication < ActiveRecord::Base
|
||||
|
||||
until children.empty?
|
||||
all.concat(children)
|
||||
children = TagImplication.where("antecedent_name IN (?) and status in (?)", children, ["active", "processing"]).all.map(&:consequent_name)
|
||||
children = TagImplication.where("antecedent_name IN (?) and status in (?)", children, ["active", "processing"]).map(&:consequent_name)
|
||||
end
|
||||
end.sort.uniq
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ class UserNameChangeRequest < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def feedback
|
||||
UserFeedback.for_user(user_id).order("id desc").all
|
||||
UserFeedback.for_user(user_id).order("id desc")
|
||||
end
|
||||
|
||||
def notify_admins
|
||||
|
@ -14,7 +14,7 @@ class WikiPagePresenter
|
||||
end
|
||||
|
||||
def consequent_tag_aliases
|
||||
@consequent_tag_aliases ||= TagAlias.where("status = 'active' and consequent_name = ?", wiki_page.title).all
|
||||
@consequent_tag_aliases ||= TagAlias.where("status = 'active' and consequent_name = ?", wiki_page.title)
|
||||
end
|
||||
|
||||
def antecedent_tag_alias
|
||||
@ -22,11 +22,11 @@ class WikiPagePresenter
|
||||
end
|
||||
|
||||
def consequent_tag_implications
|
||||
@consequent_tag_implications ||= TagImplication.where("status = 'active' and consequent_name = ?", wiki_page.title).all
|
||||
@consequent_tag_implications ||= TagImplication.where("status = 'active' and consequent_name = ?", wiki_page.title)
|
||||
end
|
||||
|
||||
def antecedent_tag_implications
|
||||
@antecedent_tag_implications ||= TagImplication.where("status = 'active' and antecedent_name = ?", wiki_page.title).all
|
||||
@antecedent_tag_implications ||= TagImplication.where("status = 'active' and antecedent_name = ?", wiki_page.title)
|
||||
end
|
||||
|
||||
# Produce a formatted page that shows the difference between two versions of a page.
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div id="a-index">
|
||||
<h1>Changes</h1>
|
||||
|
||||
<% if @post_versions.all.empty? %>
|
||||
<% if @post_versions.empty? %>
|
||||
<%= render "post_sets/blank" %>
|
||||
<% else %>
|
||||
<%= render "listing", :post_versions => @post_versions %>
|
||||
|
Loading…
Reference in New Issue
Block a user