Commit ded3b757 authored by Nick Thomas's avatar Nick Thomas Committed by Stan Hu

Stop using pluck to get deploy keys for a user

parent 0c0232e6
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment