diff options
Diffstat (limited to 'app/finders/projects/members')
-rw-r--r-- | app/finders/projects/members/effective_access_level_finder.rb | 10 | ||||
-rw-r--r-- | app/finders/projects/members/effective_access_level_per_user_finder.rb | 20 |
2 files changed, 27 insertions, 3 deletions
diff --git a/app/finders/projects/members/effective_access_level_finder.rb b/app/finders/projects/members/effective_access_level_finder.rb index 2880d6667ce..c1e3842a9e4 100644 --- a/app/finders/projects/members/effective_access_level_finder.rb +++ b/app/finders/projects/members/effective_access_level_finder.rb @@ -59,8 +59,8 @@ module Projects # @return [Array<[user_id, access_level]>] def user_ids_and_access_levels_from_all_memberships strong_memoize(:user_ids_and_access_levels_from_all_memberships) do - all_possible_avenues_of_membership.flat_map do |relation| - relation.pluck(*USER_ID_AND_ACCESS_LEVEL) # rubocop: disable CodeReuse/ActiveRecord + all_possible_avenues_of_membership.flat_map do |members| + apply_scopes(members).pluck(*USER_ID_AND_ACCESS_LEVEL) # rubocop: disable CodeReuse/ActiveRecord end end end @@ -86,7 +86,7 @@ module Projects members << Member.from_union(members_per_batch) end - members.flatten + Member.from_union(members) end def project_owner_acting_as_maintainer @@ -120,6 +120,10 @@ module Projects Arel.sql(column_alias) ) end + + def apply_scopes(members) + members + end end end end diff --git a/app/finders/projects/members/effective_access_level_per_user_finder.rb b/app/finders/projects/members/effective_access_level_per_user_finder.rb new file mode 100644 index 00000000000..f367b4ca451 --- /dev/null +++ b/app/finders/projects/members/effective_access_level_per_user_finder.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Projects + module Members + class EffectiveAccessLevelPerUserFinder < EffectiveAccessLevelFinder + def initialize(project, user) + @project = project + @user = user + end + + private + + attr_reader :user + + def apply_scopes(members) + super.where(user_id: user.id) # rubocop: disable CodeReuse/ActiveRecord + end + end + end +end |