diff options
author | Nick Thomas <nick@gitlab.com> | 2019-08-01 18:22:56 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-08-05 16:42:33 +0300 |
commit | ded3b7574dbd6e1b3249c9e5bbcc61090c733142 (patch) | |
tree | 415c06d934a4731b46fbf07423c8e69437811a17 /app | |
parent | 0c0232e623ab8d6d8cf3b4e7268d1a28d2c5f40b (diff) |
Stop using pluck to get deploy keys for a user
Diffstat (limited to 'app')
-rw-r--r-- | app/models/deploy_key.rb | 1 | ||||
-rw-r--r-- | app/models/user.rb | 11 |
2 files changed, 6 insertions, 6 deletions
diff --git a/app/models/deploy_key.rb b/app/models/deploy_key.rb index db501b4b506..fb50da39ca3 100644 --- a/app/models/deploy_key.rb +++ b/app/models/deploy_key.rb @@ -2,6 +2,7 @@ class DeployKey < Key include IgnorableColumn + include FromUnion has_many :deploy_keys_projects, inverse_of: :deploy_key, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :projects, through: :deploy_keys_projects diff --git a/app/models/user.rb b/app/models/user.rb index 74bb66d1371..4630552e02e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -933,7 +933,7 @@ class User < ApplicationRecord end def project_deploy_keys - DeployKey.unscoped.in_projects(authorized_projects.pluck(:id)).distinct(:id) + DeployKey.in_projects(authorized_projects.select(:id)).distinct(:id) end def highest_role @@ -941,11 +941,10 @@ class User < ApplicationRecord end def accessible_deploy_keys - @accessible_deploy_keys ||= begin - key_ids = project_deploy_keys.pluck(:deploy_key_id) - key_ids.push(*DeployKey.are_public.pluck(:id)) - DeployKey.where(id: key_ids) - end + DeployKey.from_union([ + DeployKey.where(id: project_deploy_keys.select(:deploy_key_id)), + DeployKey.are_public + ]) end def created_by |