Additional Rails 4.1 optimizations
This commit is contained in:
@@ -8,7 +8,11 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def posts
|
def posts
|
||||||
::Post.tag_match(@artist.name).limit(10)
|
@posts ||= begin
|
||||||
|
query = ::Post.tag_match(@artist.name).limit(10)
|
||||||
|
query.each # hack to force rails to eager load
|
||||||
|
query
|
||||||
|
end
|
||||||
rescue ::Post::SearchError
|
rescue ::Post::SearchError
|
||||||
::Post.where("false")
|
::Post.where("false")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def posts
|
def posts
|
||||||
favorites.includes(:post).map(&:post).compact
|
@posts ||= favorites.includes(:post).map(&:post).compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def presenter
|
def presenter
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def posts
|
def posts
|
||||||
::Post.where("created_at between ? and ?", min_date.beginning_of_day, max_date.end_of_day).order("score desc").limit(limit)
|
@posts ||= begin
|
||||||
|
query = ::Post.where("created_at between ? and ?", min_date.beginning_of_day, max_date.end_of_day).order("score desc").limit(limit)
|
||||||
|
query.each # hack to force rails to eager load
|
||||||
|
query
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def limit
|
def limit
|
||||||
|
|||||||
Reference in New Issue
Block a user