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
Jérome Perrin
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
Show 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,9 +391,12 @@ class User < ActiveRecord::Base
# Groups user has access to
def
authorized_groups
@authorized_groups
||=
begin
group_ids
=
(
groups
.
pluck
(
:id
)
+
authorized_projects
.
pluck
(
:namespace_id
))
Group
.
where
(
id:
group_ids
)
@authorized_groups
||=
begin
union
=
Gitlab
::
SQL
::
Union
.
new
([
groups
.
select
(
:id
),
authorized_projects
.
select
(
:namespace_id
)])
Group
.
where
(
"id IN (
#{
union
.
to_sql
}
)"
)
end
end
...
...
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