BigW Consortium Gitlab

projects_finder.rb 479 Bytes
Newer Older
1
class ProjectsFinder < UnionFinder
2
  def execute(current_user = nil, project_ids_relation = nil)
3
    segments = all_projects(current_user)
4
    segments.map! { |s| s.where(id: project_ids_relation) } if project_ids_relation
5

6
    find_union(segments, Project)
7 8 9 10
  end

  private

11
  def all_projects(current_user)
12
    projects = []
Zeger-Jan van de Weg committed
13

14 15
    projects << current_user.authorized_projects if current_user
    projects << Project.unscoped.public_to_user(current_user)
16

17
    projects
18
  end
19
end