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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/finders/users_finder.rb
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/finders/users_finder.rb')
-rw-r--r--app/finders/users_finder.rb19
1 files changed, 18 insertions, 1 deletions
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')