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

19 lines
361 B
Ruby
Raw Normal View History

2016-03-20 20:03:53 +00:00
class GroupsFinder < UnionFinder
2016-03-01 15:22:29 +00:00
def execute(current_user = nil)
segments = all_groups(current_user)
2016-03-20 20:03:53 +00:00
find_union(segments, Group).order_id_desc
2016-03-01 15:22:29 +00:00
end
private
def all_groups(current_user)
2016-03-20 20:03:53 +00:00
groups = []
groups << current_user.authorized_groups if current_user
groups << Group.unscoped.public_to_user(current_user)
2016-03-17 22:42:46 +00:00
2016-03-20 20:03:53 +00:00
groups
2016-03-17 22:42:46 +00:00
end
2016-03-01 15:22:29 +00:00
end