Commit 98043aee authored by Toon Claes's avatar Toon Claes

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.
parent 8039b9c3
...@@ -14,6 +14,33 @@ module API ...@@ -14,6 +14,33 @@ module API
authorize! access_level, merge_request authorize! access_level, merge_request
merge_request merge_request
end 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 end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment