Class: Groups::AcceptingGroupTransfersFinder

Inherits:
Base
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/finders/groups/accepting_group_transfers_finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_user, group_to_be_transferred, params = {}) ⇒ AcceptingGroupTransfersFinder

Returns a new instance of AcceptingGroupTransfersFinder.



7
8
9
10
11
# File 'app/finders/groups/accepting_group_transfers_finder.rb', line 7

def initialize(current_user, group_to_be_transferred, params = {})
  @current_user = current_user
  @group_to_be_transferred = group_to_be_transferred
  @params = params
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
20
21
22
# File 'app/finders/groups/accepting_group_transfers_finder.rb', line 13

def execute
  return Group.none unless can_transfer_group?

  items = find_all_groups

  # Search will perform an ORDER BY to ensure exact matches are returned first.
  return by_search(items, exact_matches_first: true) if params[:search].present?

  sort(items)
end