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

19 lines
381 B
Ruby
Raw Normal View History

2016-03-20 16:03:53 -04:00
class ProjectsFinder < UnionFinder
def execute(current_user = nil, options = {})
2016-03-20 16:03:53 -04:00
segments = all_projects(current_user)
2016-03-20 16:03:53 -04:00
find_union(segments, Project)
end
private
def all_projects(current_user)
2016-03-20 16:03:53 -04:00
projects = []
2016-03-20 16:03:53 -04:00
projects << current_user.authorized_projects if current_user
projects << Project.unscoped.public_to_user(current_user)
2016-03-20 16:03:53 -04:00
projects
end
end