Only select required columns, and don't call excerpt twice

This commit is contained in:
David Taylor 2017-03-08 15:42:41 +00:00
parent e20104919a
commit 8b03c459f8
1 changed files with 7 additions and 3 deletions

View File

@ -231,10 +231,14 @@ SQL
def accepted_answer_post_info def accepted_answer_post_info
# TODO: we may already have it in the stream ... so bypass query here # TODO: we may already have it in the stream ... so bypass query here
post = Post.where(id: accepted_answer_post_id, topic_id: object.topic.id).joins(:user).first postInfo = Post.where(id: accepted_answer_post_id, topic_id: object.topic.id)
excerpt = post.excerpt .joins(:user)
.pluck('post_number', 'username', 'cooked')
.first
return [post.post_number, post.username, post.excerpt(SiteSetting.solved_quote_length)] postInfo[2] = PrettyText.excerpt(postInfo[2], SiteSetting.solved_quote_length)
return postInfo
end end