Class: Projects::Members::EffectiveAccessLevelFinder

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/finders/projects/members/effective_access_level_finder.rb

Direct Known Subclasses

EffectiveAccessLevelPerUserFinder

Constant Summary collapse

USER_ID_AND_ACCESS_LEVEL =
[:user_id, :access_level].freeze
BATCH_SIZE =
5

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(project) ⇒ EffectiveAccessLevelFinder

Returns a new instance of EffectiveAccessLevelFinder.


11
12
13
# File 'app/finders/projects/members/effective_access_level_finder.rb', line 11

def initialize(project)
  @project = project
end

Instance Method Details

#executeObject


15
16
17
18
19
20
21
22
23
# File 'app/finders/projects/members/effective_access_level_finder.rb', line 15

def execute
  return Member.none if no_members?

  # rubocop: disable CodeReuse/ActiveRecord
  Member.from(generate_from_statement(user_ids_and_access_levels_from_all_memberships))
    .select([:user_id, 'MAX(access_level) AS access_level'])
    .group(:user_id)
  # rubocop: enable CodeReuse/ActiveRecord
end