diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-09 03:08:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-09 03:08:47 +0300 |
commit | 7258040618b5093cbb65035d2af4718db3a993a4 (patch) | |
tree | a33b762d2aa4bc086f39256bf296ab3b617e2ab5 /app/finders | |
parent | d48cbe178636a01db031327b93b6e3b279c12aa5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/users_finder.rb | 19 |
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') |