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

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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