summaryrefslogtreecommitdiff
path: root/app/finders/projects_finder.rb
blob: 2f0a9659d15b878a47c8555c6a0daca56d43bae2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class ProjectsFinder < UnionFinder
  def execute(current_user = nil, options = {})
    segments = all_projects(current_user)

    find_union(segments, Project)
  end

  private

  def all_projects(current_user)
    projects = []

    projects << current_user.authorized_projects if current_user
    projects << Project.unscoped.public_to_user(current_user)

    projects
  end
end