gitlab-org--gitlab-foss/app/finders/projects_finder.rb
Dmitriy Zaporozhets 2989192d1a
Store group and project full name and full path in routes table
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-02-08 19:14:29 +02:00

19 lines
490 B
Ruby

class ProjectsFinder < UnionFinder
def execute(current_user = nil, project_ids_relation = nil)
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)
projects = []
projects << current_user.authorized_projects if current_user
projects << Project.unscoped.public_to_user(current_user)
projects
end
end