gitlab-org--gitlab-foss/app/finders/projects_finder.rb

20 lines
490 B
Ruby
Raw Normal View History

2016-03-20 20:03:53 +00:00
class ProjectsFinder < UnionFinder
def execute(current_user = nil, project_ids_relation = nil)
2016-03-20 20:03:53 +00:00
segments = all_projects(current_user)
segments.map! { |s| s.where(id: project_ids_relation) } if project_ids_relation
find_union(segments, Project).with_route
end
private
def all_projects(current_user)
2016-03-20 20:03:53 +00:00
projects = []
2016-03-20 20:03:53 +00:00
projects << current_user.authorized_projects if current_user
projects << Project.unscoped.public_to_user(current_user)
2016-03-20 20:03:53 +00:00
projects
end
end