mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: when search finds a deep link in a topic it takes you to it
This commit is contained in:
@@ -8,7 +8,7 @@ class SearchController < ApplicationController
|
|||||||
|
|
||||||
def query
|
def query
|
||||||
params.require(:term)
|
params.require(:term)
|
||||||
|
|
||||||
search_args = {guardian: guardian}
|
search_args = {guardian: guardian}
|
||||||
search_args[:type_filter] = params[:type_filter] if params[:type_filter].present?
|
search_args[:type_filter] = params[:type_filter] if params[:type_filter].present?
|
||||||
if params[:include_blurbs].present?
|
if params[:include_blurbs].present?
|
||||||
|
|||||||
@@ -279,13 +279,16 @@ class Search
|
|||||||
|
|
||||||
def aggregate_search
|
def aggregate_search
|
||||||
cols = ['topics.id', 'topics.title', 'topics.slug']
|
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|
|
topics.each do |t|
|
||||||
@results.add_result(SearchResult.new(type: :topic,
|
@results.add_result(SearchResult.new(type: :topic,
|
||||||
topic_id: t[0],
|
topic_id: t[1],
|
||||||
id: t[0],
|
id: t[1],
|
||||||
title: t[1],
|
title: t[2],
|
||||||
url: "/t/#{t[2]}/#{t[0]}"))
|
url: "/t/#{t[3]}/#{t[1]}/#{t[0]}"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -110,17 +110,8 @@ describe Search do
|
|||||||
|
|
||||||
it 'returns a result' do
|
it 'returns a result' do
|
||||||
result.should be_present
|
result.should be_present
|
||||||
end
|
|
||||||
|
|
||||||
it 'has the display name as the title' do
|
|
||||||
result[:title].should == user.username
|
result[:title].should == user.username
|
||||||
end
|
|
||||||
|
|
||||||
it 'has the avatar_template is there so it can hand it to the client' do
|
|
||||||
result[:avatar_template].should_not be_nil
|
result[:avatar_template].should_not be_nil
|
||||||
end
|
|
||||||
|
|
||||||
it 'has a url for the record' do
|
|
||||||
result[:url].should == "/users/#{user.username_lower}"
|
result[:url].should == "/users/#{user.username_lower}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -196,8 +187,7 @@ describe Search do
|
|||||||
result.should be_present
|
result.should be_present
|
||||||
result[:title].should == topic.title
|
result[:title].should == topic.title
|
||||||
|
|
||||||
# The link is to the topic url because it's aggregated
|
result[:url].should == topic.relative_url + "/2"
|
||||||
result[:url].should == topic.relative_url
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user