Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-08-24 13:33:06 +0300
committerNick Thomas <nick@gitlab.com>2017-08-24 13:33:09 +0300
commit2adff699cea2cf1e60180d7eae73dfe5e8a09235 (patch)
tree0dc3c68878d5633e2103421d8debdefa1ccb5725 /lib
parent061472864ceaa4dc837eebcaa583f7b81d4e7e54 (diff)
Refactor complicated API group finding rules into GroupsFinder
Diffstat (limited to 'lib')
-rw-r--r--lib/api/groups.rb12
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/api/groups.rb b/lib/api/groups.rb
index 892fd239df4..e56427304a6 100644
--- a/lib/api/groups.rb
+++ b/lib/api/groups.rb
@@ -47,16 +47,8 @@ module API
use :pagination
end
get do
- groups = if params[:owned]
- current_user ? current_user.owned_groups : Group.none
- elsif current_user&.admin?
- Group.all
- elsif params[:all_available] || current_user.nil?
- GroupsFinder.new(current_user).execute
- else
- current_user.groups
- end
-
+ find_params = { all_available: params[:all_available], owned: params[:owned] }
+ groups = GroupsFinder.new(current_user, find_params).execute
groups = groups.search(params[:search]) if params[:search].present?
groups = groups.where.not(id: params[:skip_groups]) if params[:skip_groups].present?
groups = groups.reorder(params[:order_by] => params[:sort])