summaryrefslogtreecommitdiff
path: root/app/serializers/group_child_entity.rb
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-09-10 18:43:15 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2017-10-04 22:49:41 +0200
commit79cc3c8e3e7938ea53459e34ca585ae66791199e (patch)
tree59b51c70d1ed62b26a185efa6687257202de0629 /app/serializers/group_child_entity.rb
parentbb5187bb2a71f87b3ff49388f70dbcb27dfe4c6a (diff)
downloadgitlab-ce-79cc3c8e3e7938ea53459e34ca585ae66791199e.tar.gz
Limit the amount of queries per row
Diffstat (limited to 'app/serializers/group_child_entity.rb')
-rw-r--r--app/serializers/group_child_entity.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/app/serializers/group_child_entity.rb b/app/serializers/group_child_entity.rb
index bc870541795..ab0d8a32312 100644
--- a/app/serializers/group_child_entity.rb
+++ b/app/serializers/group_child_entity.rb
@@ -32,11 +32,9 @@ class GroupChildEntity < Grape::Entity
end
def permission
- if project?
- object.project_members.find_by(user_id: request.current_user)&.human_access
- else
- object.group_members.find_by(user_id: request.current_user)&.human_access
- end
+ return unless request&.current_user
+
+ request.current_user.members.find_by(source: object)&.human_access
end
# Project only attributes