Commit 090eeb58 authored by Yorick Peterse's avatar Yorick Peterse

Added changelog for user search improvements

parent 41bfe82b
...@@ -58,7 +58,7 @@ class AutocompleteUsersFinder ...@@ -58,7 +58,7 @@ class AutocompleteUsersFinder
def users_from_project def users_from_project
if author_id.present? if author_id.present?
union = Gitlab::SQL::Union union = Gitlab::SQL::Union
.new([project.team.users, User.where(id: author_id)]) .new([project.authorized_users, User.where(id: author_id)])
User.from("(#{union.to_sql}) #{User.table_name}") User.from("(#{union.to_sql}) #{User.table_name}")
else else
......
---
title: Improve performance of searching for and autocompleting of users
merge_request:
author:
type: performance
...@@ -38,16 +38,14 @@ module Gitlab ...@@ -38,16 +38,14 @@ module Gitlab
if words.any? if words.any?
words.map { |word| arel_table[column].matches(to_pattern(word)) }.reduce(:and) words.map { |word| arel_table[column].matches(to_pattern(word)) }.reduce(:and)
else else
sanitized_query = sanitize_sql_like(query)
# No words of at least 3 chars, but we can search for an exact # No words of at least 3 chars, but we can search for an exact
# case insensitive match with the query as a whole # case insensitive match with the query as a whole
if lower_exact_match if lower_exact_match
Arel::Nodes::NamedFunction Arel::Nodes::NamedFunction
.new('LOWER', [arel_table[column]]) .new('LOWER', [arel_table[column]])
.eq(sanitized_query) .eq(query)
else else
arel_table[column].matches(sanitized_query) arel_table[column].matches(sanitize_sql_like(query))
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment