diff options
Diffstat (limited to 'app/finders/groups_finder.rb')
-rw-r--r-- | app/finders/groups_finder.rb | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/app/finders/groups_finder.rb b/app/finders/groups_finder.rb index 30698f80231..4e43f42e9e1 100644 --- a/app/finders/groups_finder.rb +++ b/app/finders/groups_finder.rb @@ -1,30 +1,18 @@ -class GroupsFinder +class GroupsFinder < UnionFinder def execute(current_user = nil) segments = all_groups(current_user) - if segments.length > 1 - union = Gitlab::SQL::Union.new(segments.map { |s| s.select(:id) }) - Group.where("namespaces.id IN (#{union.to_sql})").order_id_desc - else - segments.first - end + find_union(segments, Group).order_id_desc end private def all_groups(current_user) - if current_user - user_groups(current_user) - else - [Group.unscoped.public_only] - end - end + groups = [] + + groups << current_user.authorized_groups if current_user + groups << Group.unscoped.public_to_user(current_user) - def user_groups(current_user) - if current_user.external? - [current_user.authorized_groups, Group.unscoped.public_only] - else - [current_user.authorized_groups, Group.unscoped.public_and_internal_only] - end + groups end end |