Stop using pluck to get deploy keys for a user
This commit is contained in:
parent
0c0232e623
commit
ded3b7574d
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
class DeployKey < Key
|
class DeployKey < Key
|
||||||
include IgnorableColumn
|
include IgnorableColumn
|
||||||
|
include FromUnion
|
||||||
|
|
||||||
has_many :deploy_keys_projects, inverse_of: :deploy_key, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
|
has_many :deploy_keys_projects, inverse_of: :deploy_key, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
|
||||||
has_many :projects, through: :deploy_keys_projects
|
has_many :projects, through: :deploy_keys_projects
|
||||||
|
|
|
@ -933,7 +933,7 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_deploy_keys
|
def project_deploy_keys
|
||||||
DeployKey.unscoped.in_projects(authorized_projects.pluck(:id)).distinct(:id)
|
DeployKey.in_projects(authorized_projects.select(:id)).distinct(:id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def highest_role
|
def highest_role
|
||||||
|
@ -941,11 +941,10 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def accessible_deploy_keys
|
def accessible_deploy_keys
|
||||||
@accessible_deploy_keys ||= begin
|
DeployKey.from_union([
|
||||||
key_ids = project_deploy_keys.pluck(:deploy_key_id)
|
DeployKey.where(id: project_deploy_keys.select(:deploy_key_id)),
|
||||||
key_ids.push(*DeployKey.are_public.pluck(:id))
|
DeployKey.are_public
|
||||||
DeployKey.where(id: key_ids)
|
])
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def created_by
|
def created_by
|
||||||
|
|
Loading…
Reference in New Issue