mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
HACK: allow for multiple hits on same topic for search
This commit is contained in:
@@ -92,7 +92,10 @@ class TopicQuery
|
||||
.joins("JOIN (#{sql}) X on X.id = topics.id")
|
||||
.order("X.pos")
|
||||
|
||||
posts_map = Hash[*search.posts.map{|p| [p.topic_id, p]}.flatten]
|
||||
posts_map = {}
|
||||
search.posts.each do |p|
|
||||
(posts_map[p.topic_id] ||= []) << p
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -107,8 +110,10 @@ class TopicQuery
|
||||
|
||||
|
||||
list.topics.each do |topic|
|
||||
if post = posts_map[topic.id]
|
||||
topic.search_data = {excerpt: search.blurb(post), post_number: post.post_number}
|
||||
if posts = posts_map[topic.id]
|
||||
if post = posts.shift
|
||||
topic.search_data = {excerpt: search.blurb(post), post_number: post.post_number}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user