Only return required info for dynamic user lists (#2397)

This commit is contained in:
Ahmad Farhat 2020-12-30 17:39:31 -05:00 committed by GitHub
parent 85b8cac9fe
commit cf3b450743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 4 deletions

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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