summaryrefslogtreecommitdiff
path: root/app/finders/groups/accepting_project_imports_finder.rb
blob: 55d72edf7bbe4d6b7a42938605d6052d4ffd3461 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

module Groups
  class AcceptingProjectImportsFinder
    def initialize(current_user)
      @current_user = current_user
    end

    def execute
      ::Group.from_union(
        [
          current_user.manageable_groups,
          managable_groups_originating_from_group_shares
        ]
      )
    end

    private

    attr_reader :current_user

    def managable_groups_originating_from_group_shares
      GroupGroupLink
        .with_owner_or_maintainer_access
        .groups_accessible_via(
          current_user.owned_or_maintainers_groups
          .select(:id)
        )
    end
  end
end