2016-03-20 20:03:53 +00:00
|
|
|
class ProjectsFinder < UnionFinder
|
2015-11-18 11:21:06 +00:00
|
|
|
def execute(current_user = nil, options = {})
|
2016-03-20 20:03:53 +00:00
|
|
|
segments = all_projects(current_user)
|
2014-02-25 17:15:08 +00:00
|
|
|
|
2016-03-20 20:03:53 +00:00
|
|
|
find_union(segments, Project)
|
2014-02-25 17:15:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2014-06-05 17:37:35 +00:00
|
|
|
def all_projects(current_user)
|
2016-03-20 20:03:53 +00:00
|
|
|
projects = []
|
2016-03-10 21:08:11 +00:00
|
|
|
|
2016-03-20 20:03:53 +00:00
|
|
|
projects << current_user.authorized_projects if current_user
|
|
|
|
projects << Project.unscoped.public_to_user(current_user)
|
2015-11-18 11:21:06 +00:00
|
|
|
|
2016-03-20 20:03:53 +00:00
|
|
|
projects
|
2015-11-18 11:21:06 +00:00
|
|
|
end
|
2014-02-25 17:15:08 +00:00
|
|
|
end
|