Skip to content

Commit

Permalink
Only return required info for dynamic user lists (#2397)
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad committed Dec 30, 2020
1 parent 85b8cac commit cf3b450
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ def merge_user
# 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

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ def shared_access_list
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

Expand Down

0 comments on commit cf3b450

Please sign in to comment.