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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
a54b2e80
Commit
a54b2e80
authored
Dec 30, 2012
by
Jakub Jirutka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize query for keys of repository members
…to load them at once and then use query cache.
parent
82ae973a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
app/roles/authority.rb
app/roles/authority.rb
+13
-9
No files found.
app/roles/authority.rb
View file @
a54b2e80
...
@@ -25,21 +25,25 @@ module Authority
...
@@ -25,21 +25,25 @@ module Authority
end
end
def
repository_readers
def
repository_readers
keys
=
Key
.
joins
({
user: :users_projects
}).
repository_members
[
UsersProject
::
REPORTER
]
where
(
"users_projects.project_id = ? AND users_projects.project_access = ?"
,
id
,
UsersProject
::
REPORTER
)
keys
.
map
(
&
:identifier
)
+
deploy_keys
.
map
(
&
:identifier
)
end
end
def
repository_writers
def
repository_writers
keys
=
Key
.
joins
({
user: :users_projects
}).
repository_members
[
UsersProject
::
DEVELOPER
]
where
(
"users_projects.project_id = ? AND users_projects.project_access = ?"
,
id
,
UsersProject
::
DEVELOPER
)
keys
.
map
(
&
:identifier
)
end
end
def
repository_masters
def
repository_masters
keys
=
Key
.
joins
({
user: :users_projects
}).
repository_members
[
UsersProject
::
MASTER
]
where
(
"users_projects.project_id = ? AND users_projects.project_access = ?"
,
id
,
UsersProject
::
MASTER
)
end
keys
.
map
(
&
:identifier
)
def
repository_members
keys
=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
[]
}
UsersProject
.
select
(
"keys.identifier, project_access"
).
joins
(
user: :keys
).
where
(
project_id:
id
).
each
{
|
row
|
keys
[
row
.
project_access
]
<<
[
row
.
identifier
]
}
keys
[
UsersProject
::
REPORTER
]
+=
deploy_keys
.
pluck
(
:identifier
)
keys
end
end
def
allow_read_for?
(
user
)
def
allow_read_for?
(
user
)
...
...
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