summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-07-14 16:41:11 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-07-14 16:41:11 +0000
commit0f393724e7de8d764577b6622ccf43964539cb2b (patch)
treef192f64badd0ab5b662c50a2ace3b49f349da5b9 /app
parente318afbed70da9780c5deeb735f6acc8ab9327a1 (diff)
parent574b3efd6bfe7df64ec704844f2619c547731aa6 (diff)
downloadgitlab-ce-0f393724e7de8d764577b6622ccf43964539cb2b.tar.gz
Merge branch 'fix-exact-matches-of-username-and-email-on-top-of-the-user-search' into 'master'
Fixes the user order being overriden in the autocomplete controller See merge request !12868
Diffstat (limited to 'app')
-rw-r--r--app/controllers/autocomplete_controller.rb4
-rw-r--r--app/models/user.rb2
2 files changed, 3 insertions, 3 deletions
diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb
index fe331a883c1..3120916c5bb 100644
--- a/app/controllers/autocomplete_controller.rb
+++ b/app/controllers/autocomplete_controller.rb
@@ -5,10 +5,10 @@ class AutocompleteController < ApplicationController
def users
@users ||= User.none
- @users = @users.search(params[:search]) if params[:search].present?
- @users = @users.where.not(id: params[:skip_users]) if params[:skip_users].present?
@users = @users.active
@users = @users.reorder(:name)
+ @users = @users.search(params[:search]) if params[:search].present?
+ @users = @users.where.not(id: params[:skip_users]) if params[:skip_users].present?
@users = @users.page(params[:page]).per(params[:per_page])
if params[:todo_filter].present? && current_user
diff --git a/app/models/user.rb b/app/models/user.rb
index dd1a391773a..8f40af24e20 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -314,7 +314,7 @@ class User < ActiveRecord::Base
table[:name].matches(pattern)
.or(table[:email].matches(pattern))
.or(table[:username].matches(pattern))
- ).reorder(order % { query: ActiveRecord::Base.connection.quote(query) }, id: :desc)
+ ).reorder(order % { query: ActiveRecord::Base.connection.quote(query) }, :name)
end
# searches user by given pattern