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
189c40c3
Commit
189c40c3
authored
Nov 12, 2015
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use SQL::Union for User#authorized_groups
This removes the need for plucking any IDs into Ruby.
parent
656d9ff6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
app/models/user.rb
app/models/user.rb
+7
-4
No files found.
app/models/user.rb
View file @
189c40c3
...
@@ -391,10 +391,13 @@ class User < ActiveRecord::Base
...
@@ -391,10 +391,13 @@ class User < ActiveRecord::Base
# Groups user has access to
# Groups user has access to
def
authorized_groups
def
authorized_groups
@authorized_groups
||=
begin
@authorized_groups
||=
group_ids
=
(
groups
.
pluck
(
:id
)
+
authorized_projects
.
pluck
(
:namespace_id
))
begin
Group
.
where
(
id:
group_ids
)
union
=
Gitlab
::
SQL
::
Union
.
end
new
([
groups
.
select
(
:id
),
authorized_projects
.
select
(
:namespace_id
)])
Group
.
where
(
"id IN (
#{
union
.
to_sql
}
)"
)
end
end
end
# Projects user has access to
# Projects user has access to
...
...
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