From 8b03c459f8e26fed86a5cd53ad3985829bb96ba4 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 8 Mar 2017 15:42:41 +0000 Subject: [PATCH] Only select required columns, and don't call excerpt twice --- plugin.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugin.rb b/plugin.rb index 615280b..d923257 100644 --- a/plugin.rb +++ b/plugin.rb @@ -231,10 +231,14 @@ SQL def accepted_answer_post_info # 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 - excerpt = post.excerpt + postInfo = Post.where(id: accepted_answer_post_id, topic_id: object.topic.id) + .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