summaryrefslogtreecommitdiff
path: root/app/models/member.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-06-28 09:02:27 -0700
committerStan Hu <stanhu@gmail.com>2016-06-29 03:12:57 -0700
commite21c7d37c8cd21be1489f6dd445d5efa24e94456 (patch)
treec89ab8603436945ecc62b45f2dd3dd3b51423cd8 /app/models/member.rb
parent1023289605f075cef86833ab5c1b0e87d967f69e (diff)
downloadgitlab-ce-e21c7d37c8cd21be1489f6dd445d5efa24e94456.tar.gz
Reduce overhead and optimize ProjectTeam#max_member_access performance
The previous implementation would load the entire team member list and their respective attributes. Now we only search for the user's specific access level. In gitlab-com/operations#42, this reduces the overall overhead of rendering the issue from 28% to 20%. First step of optimizing #19273
Diffstat (limited to 'app/models/member.rb')
-rw-r--r--app/models/member.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/app/models/member.rb b/app/models/member.rb
index c74a16367db..57161397e2b 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -32,6 +32,7 @@ class Member < ActiveRecord::Base
scope :request, -> { where.not(requested_at: nil) }
scope :non_request, -> { where(requested_at: nil) }
scope :non_pending, -> { non_request.non_invite }
+ scope :has_access, -> { where('access_level > 0') }
scope :guests, -> { where(access_level: GUEST) }
scope :reporters, -> { where(access_level: REPORTER) }