diff --git a/Gemfile b/Gemfile index 71eb734aad69a25394b6d1f64b4572549e15e9a1..ef568015a30df52e55f214a988c2ce847a2e60e3 100644 --- a/Gemfile +++ b/Gemfile @@ -80,6 +80,8 @@ gem 'cancancan', '~> 2.0' gem 'aws-sdk-s3', '~> 1.75' gem 'google-cloud-storage', '~> 1.26' +gem 'pluck_to_hash', '~> 1.0.2' + group :production do # Use a postgres database in production. gem 'pg', '~> 0.18' diff --git a/Gemfile.lock b/Gemfile.lock index 0d795470a2700d1e1d68b1756b7f385422b574d4..97fd7630f4b4d309a23af35aaffad53ca57b799f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -256,6 +256,9 @@ GEM parser (2.7.1.3) ast (~> 2.4.0) pg (0.21.0) + pluck_to_hash (1.0.2) + activerecord (>= 4.0.2) + activesupport (>= 4.0.2) popper_js (1.16.0) public_suffix (4.0.5) puma (3.12.6) @@ -443,6 +446,7 @@ DEPENDENCIES omniauth-twitter pagy pg (~> 0.18) + pluck_to_hash (~> 1.0.2) puma (~> 3.12) rails (~> 5.2.4.4) rails-controller-testing diff --git a/app/controllers/admins_controller.rb b/app/controllers/admins_controller.rb index 5c4b106e314debc29a6e31d456faa395b24d7461..d51aeca0fcf9a1f250e897aaa2ff5dadc908ee58 100644 --- a/app/controllers/admins_controller.rb +++ b/app/controllers/admins_controller.rb @@ -199,10 +199,10 @@ class AdminsController < ApplicationController # GET /admins/merge_list def merge_list # Returns a list of users that can merged into another user - initial_list = User.select(:uid, :name, :email) - .without_role(:super_admin) + initial_list = User.without_role(:super_admin) .where.not(uid: current_user.uid) .merge_list_search(params[:search]) + .pluck_to_hash(:uid, :name, :email) initial_list = initial_list.where(provider: @user_domain) if Rails.configuration.loadbalanced_configuration diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ac60331754471488a42d655c2f83e62690528db4..98db31e0e1a6b1b2fb713a2165929b44c049c25f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -209,10 +209,10 @@ class UsersController < ApplicationController roles_can_appear << role.name if role.get_permission("can_appear_in_share_list") && role.priority >= 0 end - initial_list = User.select(:uid, :name) - .where.not(uid: current_user.uid) + initial_list = User.where.not(uid: current_user.uid) .with_role(roles_can_appear) .shared_list_search(params[:search]) + .pluck_to_hash(:uid, :name) initial_list = initial_list.where(provider: @user_domain) if Rails.configuration.loadbalanced_configuration