mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Incorrect search blurb when advanced search filters are used take2
Also remove include_blurbs attribute which isn't used.
This commit is contained in:
@@ -23,19 +23,20 @@ class Search
|
||||
:more_users,
|
||||
:term,
|
||||
:search_context,
|
||||
:include_blurbs,
|
||||
:more_full_page_results,
|
||||
:error
|
||||
)
|
||||
|
||||
attr_accessor :search_log_id
|
||||
|
||||
def initialize(type_filter, term, search_context, include_blurbs, blurb_length)
|
||||
BLURB_LENGTH = 200
|
||||
|
||||
def initialize(type_filter:, term:, search_context:, blurb_length: nil, blurb_term: nil)
|
||||
@type_filter = type_filter
|
||||
@term = term
|
||||
@blurb_term = blurb_term || term
|
||||
@search_context = search_context
|
||||
@include_blurbs = include_blurbs
|
||||
@blurb_length = blurb_length || 200
|
||||
@blurb_length = blurb_length || BLURB_LENGTH
|
||||
@posts = []
|
||||
@categories = []
|
||||
@users = []
|
||||
@@ -57,7 +58,7 @@ class Search
|
||||
end
|
||||
|
||||
def blurb(post)
|
||||
GroupedSearchResults.blurb_for(post.cooked, @term, @blurb_length)
|
||||
GroupedSearchResults.blurb_for(post.cooked, @blurb_term, @blurb_length)
|
||||
end
|
||||
|
||||
def add(object)
|
||||
@@ -72,7 +73,7 @@ class Search
|
||||
end
|
||||
end
|
||||
|
||||
def self.blurb_for(cooked, term = nil, blurb_length = 200)
|
||||
def self.blurb_for(cooked, term = nil, blurb_length = BLURB_LENGTH)
|
||||
blurb = nil
|
||||
cooked = SearchIndexer.scrub_html_for_search(cooked)
|
||||
|
||||
@@ -91,14 +92,11 @@ class Search
|
||||
end
|
||||
|
||||
if term
|
||||
terms = term.split(/\s+/)
|
||||
phrase = terms.first
|
||||
|
||||
if phrase =~ Regexp.new(Search::PHRASE_MATCH_REGEXP_PATTERN)
|
||||
phrase = Regexp.last_match[1]
|
||||
if term =~ Regexp.new(Search::PHRASE_MATCH_REGEXP_PATTERN)
|
||||
term = Regexp.last_match[1]
|
||||
end
|
||||
|
||||
blurb = TextHelper.excerpt(cooked, phrase,
|
||||
blurb = TextHelper.excerpt(cooked, term,
|
||||
radius: blurb_length / 2
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user