diff options
Diffstat (limited to 'app/finders/users_finder.rb')
-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') |