2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 09:10:25 +08:00

FIX: when search finds a deep link in a topic it takes you to it

This commit is contained in:
Sam 2014-08-28 17:15:53 +10:00
parent 9897660a36
commit a1244043d3
3 changed files with 10 additions and 17 deletions

View file

@ -279,13 +279,16 @@ class Search
def aggregate_search
cols = ['topics.id', 'topics.title', 'topics.slug']
topics = posts_query(@limit, aggregate_search: true).group(*cols).pluck(*cols)
topics = posts_query(@limit, aggregate_search: true)
.group(*cols)
.pluck('min(posts.post_number)',*cols)
topics.each do |t|
@results.add_result(SearchResult.new(type: :topic,
topic_id: t[0],
id: t[0],
title: t[1],
url: "/t/#{t[2]}/#{t[0]}"))
topic_id: t[1],
id: t[1],
title: t[2],
url: "/t/#{t[3]}/#{t[1]}/#{t[0]}"))
end
end