From 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 18 Jun 2020 11:18:50 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-1-stable-ee --- app/finders/users_finder.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'app/finders/users_finder.rb') diff --git a/app/finders/users_finder.rb b/app/finders/users_finder.rb index ebb686c2aa7..f87e0c67604 100644 --- a/app/finders/users_finder.rb +++ b/app/finders/users_finder.rb @@ -15,6 +15,8 @@ # blocked: boolean # external: boolean # without_projects: boolean +# sort: string +# id: integer # class UsersFinder include CreatedAtFilter @@ -30,6 +32,7 @@ class UsersFinder def execute users = User.all.order_id_desc users = by_username(users) + users = by_id(users) users = by_search(users) users = by_blocked(users) users = by_active(users) @@ -40,7 +43,7 @@ class UsersFinder users = by_without_projects(users) users = by_custom_attributes(users) - users + order(users) end private @@ -51,6 +54,12 @@ class UsersFinder users.by_username(params[:username]) end + def by_id(users) + return users unless params[:id] + + users.id_in(params[:id]) + end + def by_search(users) return users unless params[:search].present? @@ -102,6 +111,14 @@ class UsersFinder users.without_projects end + + # rubocop: disable CodeReuse/ActiveRecord + def order(users) + return users unless params[:sort] + + users.order_by(params[:sort]) + end + # rubocop: enable CodeReuse/ActiveRecord end UsersFinder.prepend_if_ee('EE::UsersFinder') -- cgit v1.2.3