Commit f3de17fd authored by Yorick Peterse's avatar Yorick Peterse Committed by Robert Speicher

Merge branch 'make-max-member-access-faster' into 'master'

Reduce overhead and optimize ProjectTeam#max_member_access performance

See merge request !4973
(cherry picked from commit d33991f8)
parent 428f5630
...@@ -13,6 +13,7 @@ v 8.9.3 ...@@ -13,6 +13,7 @@ v 8.9.3
- Fixed avatar alignment in new MR view. !4901 - Fixed avatar alignment in new MR view. !4901
- Removed fade when filtering results. !4932 - Removed fade when filtering results. !4932
- Fix missing avatar on system notes. !4954 - Fix missing avatar on system notes. !4954
- Reduce overhead and optimize ProjectTeam#max_member_access performance. !4973
v 8.9.2 v 8.9.2
- Fix visibility of snippets when searching. - Fix visibility of snippets when searching.
......
...@@ -32,6 +32,7 @@ class Member < ActiveRecord::Base ...@@ -32,6 +32,7 @@ class Member < ActiveRecord::Base
scope :request, -> { where.not(requested_at: nil) } scope :request, -> { where.not(requested_at: nil) }
scope :non_request, -> { where(requested_at: nil) } scope :non_request, -> { where(requested_at: nil) }
scope :non_pending, -> { non_request.non_invite } scope :non_pending, -> { non_request.non_invite }
scope :has_access, -> { where('access_level > 0') }
scope :guests, -> { where(access_level: GUEST) } scope :guests, -> { where(access_level: GUEST) }
scope :reporters, -> { where(access_level: REPORTER) } scope :reporters, -> { where(access_level: REPORTER) }
......
...@@ -137,20 +137,10 @@ class ProjectTeam ...@@ -137,20 +137,10 @@ class ProjectTeam
def max_member_access(user_id) def max_member_access(user_id)
access = [] access = []
project.members.non_request.each do |member| access += project.members.non_request.where(user_id: user_id).has_access.pluck(:access_level)
if member.user_id == user_id
access << member.access_field if member.access_field
break
end
end
if group if group
group.members.non_request.each do |member| access += group.members.non_request.where(user_id: user_id).has_access.pluck(:access_level)
if member.user_id == user_id
access << member.access_field if member.access_field
break
end
end
end end
if project.invited_groups.any? && project.allowed_to_share_with_group? if project.invited_groups.any? && project.allowed_to_share_with_group?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment