summaryrefslogtreecommitdiff
path: root/app/finders/groups_finder.rb
blob: 4e43f42e9e18d51e355b5abe4c0891247f8f6740 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class GroupsFinder < UnionFinder
  def execute(current_user = nil)
    segments = all_groups(current_user)

    find_union(segments, Group).order_id_desc
  end

  private

  def all_groups(current_user)
    groups = []

    groups << current_user.authorized_groups if current_user
    groups << Group.unscoped.public_to_user(current_user)

    groups
  end
end