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.
This commit is contained in:
Toon Claes 2017-05-22 16:42:10 +02:00
parent 8039b9c3c6
commit 98043aeedf
1 changed files with 27 additions and 0 deletions

View File

@ -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