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