FIX: Topic.similar_to results in error if cooked raw is blank.

This commit is contained in:
Guo Xiang Tan
2020-08-21 10:51:37 +08:00
parent 2aa1482421
commit aae9e6e5fd
2 changed files with 11 additions and 5 deletions

View File

@@ -597,12 +597,14 @@ class Topic < ActiveRecord::Base
PrettyText.cook(raw[0...MAX_SIMILAR_BODY_LENGTH].strip)
)
raw_tsquery = Search.set_tsquery_weight_filter(
Search.prepare_data(cooked),
'B'
)
if cooked.present?
raw_tsquery = Search.set_tsquery_weight_filter(
Search.prepare_data(cooked),
'B'
)
tsquery = "#{tsquery} & #{raw_tsquery}"
tsquery = "#{tsquery} & #{raw_tsquery}"
end
end
tsquery = Search.to_tsquery(term: tsquery, joiner: "|")