Add excerpt column to topics table to remove N+1 query in ListableTopicSerializer

This commit is contained in:
Neil Lalonde
2014-03-18 13:40:40 -04:00
parent 3cf0adaed0
commit 0b1550f9d4
6 changed files with 50 additions and 5 deletions

View File

@@ -64,11 +64,6 @@ class ListableTopicSerializer < BasicTopicSerializer
pinned
end
def excerpt
# excerpt should be hoisted into topic, this is an N+1 query ... yuck
object.posts.by_post_number.first.try(:excerpt, 220, strip_links: true) || nil
end
def pinned
PinnedCheck.new(object, object.user_data).pinned?
end