Skip to content

Commit

Permalink
FIX: include pinned status in search results
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSaffron committed Mar 18, 2016
1 parent 88f38f3 commit 50f7616
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/search_controller.rb
Expand Up @@ -25,6 +25,8 @@ def show
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|
Expand Down
8 changes: 8 additions & 0 deletions lib/search/grouped_search_results.rb
Expand Up @@ -25,6 +25,14 @@ def initialize(type_filter, term, search_context, include_blurbs, blurb_length)
@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
Expand Down

0 comments on commit 50f7616

Please sign in to comment.