diff options
author | Toon Claes <toon@gitlab.com> | 2017-05-22 16:42:10 +0200 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2017-05-30 22:38:28 +0200 |
commit | 98043aeedf1fe3241d8362d8036f28b709e6d468 (patch) | |
tree | 8d4e5acf782a701ee0b69a8a8a31a9abd0b92c4b /lib | |
parent | 8039b9c3c6caedc19e0e44d086a007e8975134b7 (diff) | |
download | gitlab-ce-98043aeedf1fe3241d8362d8036f28b709e6d468.tar.gz |
Copy `filter_projects` helper to V3
The helper will be modified in V4, so copy the original to V4 to keep the
current behavior in V3.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/v3/helpers.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/api/v3/helpers.rb b/lib/api/v3/helpers.rb index 0f234d4cdad..06af286ef50 100644 --- a/lib/api/v3/helpers.rb +++ b/lib/api/v3/helpers.rb @@ -14,6 +14,33 @@ module API authorize! access_level, merge_request merge_request end + + # project helpers + + def filter_projects(projects) + if params[:membership] + projects = projects.merge(current_user.authorized_projects) + end + + if params[:owned] + projects = projects.merge(current_user.owned_projects) + end + + if params[:starred] + projects = projects.merge(current_user.starred_projects) + end + + if params[:search].present? + projects = projects.search(params[:search]) + end + + if params[:visibility].present? + projects = projects.search_by_visibility(params[:visibility]) + end + + projects = projects.where(archived: params[:archived]) + projects.reorder(params[:order_by] => params[:sort]) + end end end end |