FIX: include pinned status in search results

This commit is contained in:
Sam 2016-03-18 16:26:20 +11:00
parent 88f38f34cc
commit 50f7616d04
2 changed files with 10 additions and 0 deletions

View File

@ -25,6 +25,8 @@ class SearchController < ApplicationController
search = Search.new(params[:q], search_args)
result = search.execute
result.find_user_data(guardian)
serializer = serialize_data(result, GroupedSearchResultSerializer, result: result)
respond_to do |format|

View File

@ -25,6 +25,14 @@ class Search
@users = []
end
def find_user_data(guardian)
if user = guardian.user
topics = @posts.map(&:topic)
topic_lookup = TopicUser.lookup_for(user, topics)
topics.each { |ft| ft.user_data = topic_lookup[ft.id] }
end
end
def blurb(post)
GroupedSearchResults.blurb_for(post.cooked, @term, @blurb_length)
end