Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
ded3b757
Commit
ded3b757
authored
Aug 01, 2019
by
Nick Thomas
Committed by
Stan Hu
Aug 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop using pluck to get deploy keys for a user
parent
0c0232e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
app/models/deploy_key.rb
app/models/deploy_key.rb
+1
-0
app/models/user.rb
app/models/user.rb
+5
-6
No files found.
app/models/deploy_key.rb
View file @
ded3b757
...
@@ -2,6 +2,7 @@
...
@@ -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
...
...
app/models/user.rb
View file @
ded3b757
...
@@ -933,7 +933,7 @@ class User < ApplicationRecord
...
@@ -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
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment