Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-11-24 14:24:24 +0300
committerDouwe Maan <douwe@selenight.nl>2017-11-27 13:29:40 +0300
commitda42dfb3cf4a2fb0cdcc1a3b41438516a0bed0e5 (patch)
tree1dc5014e27ce049e47e8670b83b79e0c49bb96b9 /app/models/snippet.rb
parentd4eea275310867eccc927d0e92a1d19a165f0668 (diff)
Use fuzzy search with minimum length of 3 characters where appropriate
Diffstat (limited to 'app/models/snippet.rb')
-rw-r--r--app/models/snippet.rb7
1 files changed, 2 insertions, 5 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index e621404f3ae..05a16f11b59 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -136,10 +136,7 @@ class Snippet < ActiveRecord::Base
#
# Returns an ActiveRecord::Relation.
def search(query)
- t = arel_table
- pattern = to_pattern(query)
-
- where(t[:title].matches(pattern).or(t[:file_name].matches(pattern)))
+ fuzzy_search(query, [:title, :file_name])
end
# Searches for snippets with matching content.
@@ -150,7 +147,7 @@ class Snippet < ActiveRecord::Base
#
# Returns an ActiveRecord::Relation.
def search_code(query)
- where(arel_table[:content].matches(to_pattern(query)))
+ fuzzy_search(query, [:content])
end
end
end