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
Boxiang Sun
gitlab-ce
Commits
b9c12be5
Commit
b9c12be5
authored
Oct 10, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't preload all memberships for a user
parent
6f5a2276
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
10 deletions
+1
-10
app/models/user.rb
app/models/user.rb
+0
-9
app/serializers/group_child_entity.rb
app/serializers/group_child_entity.rb
+1
-1
No files found.
app/models/user.rb
View file @
b9c12be5
...
...
@@ -1073,15 +1073,6 @@ class User < ActiveRecord::Base
super
end
# Get the membership for an object without loading the source of the membership
#
# This loads the entire `members` relation of the user, used on `current_user`
def
membership_for_object
(
object
)
members
.
sort
(
'access_level_asc'
).
detect
do
|
member
|
object
.
is_a?
(
member
.
source_type
.
constantize
)
&&
member
.
source_id
==
object
.
id
end
end
protected
# override, from Devise::Validatable
...
...
app/serializers/group_child_entity.rb
View file @
b9c12be5
...
...
@@ -72,7 +72,7 @@ class GroupChildEntity < Grape::Entity
def
membership
return
unless
request
.
current_user
@membership
||=
request
.
current_user
.
members
hip_for_object
(
object
)
@membership
||=
request
.
current_user
.
members
.
find_by
(
source:
object
)
end
def
project?
...
...
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