diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-30 06:07:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-30 06:07:30 +0300 |
commit | dbb27a91536f29550f7714356ab499d318e9d7e2 (patch) | |
tree | ab0aa16d03a04aec036d18cce0992f81d594026e /app/models/concerns/issuable.rb | |
parent | e222250937b497b4cf6e9b8e5ddde0097f0e0954 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/concerns/issuable.rb')
-rw-r--r-- | app/models/concerns/issuable.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 2d06247a486..9424bcf0424 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -31,6 +31,7 @@ module Issuable TITLE_HTML_LENGTH_MAX = 800 DESCRIPTION_LENGTH_MAX = 1.megabyte DESCRIPTION_HTML_LENGTH_MAX = 5.megabytes + SEARCHABLE_FIELDS = %w(title description).freeze STATE_ID_MAP = { opened: 1, @@ -264,15 +265,16 @@ module Issuable # matched_columns - Modify the scope of the query. 'title', 'description' or joining them with a comma. # # Returns an ActiveRecord::Relation. - def full_search(query, matched_columns: 'title,description', use_minimum_char_limit: true) - allowed_columns = [:title, :description] - matched_columns = matched_columns.to_s.split(',').map(&:to_sym) - matched_columns &= allowed_columns + def full_search(query, matched_columns: nil, use_minimum_char_limit: true) + if matched_columns + matched_columns = matched_columns.to_s.split(',') + matched_columns &= SEARCHABLE_FIELDS + matched_columns.map!(&:to_sym) + end - # Matching title or description if the matched_columns did not contain any allowed columns. - matched_columns = [:title, :description] if matched_columns.empty? + search_columns = matched_columns.presence || [:title, :description] - fuzzy_search(query, matched_columns, use_minimum_char_limit: use_minimum_char_limit) + fuzzy_search(query, search_columns, use_minimum_char_limit: use_minimum_char_limit) end def simple_sorts |