Skip to content
Snippets Groups Projects
Commit c50fda56 authored by Izaak Alpert's avatar Izaak Alpert Committed by Wes Gurney
Browse files

Used pagnation function from api helpers

Change-Id: I1bdd3608d3b46924b5da3ae282c99f85ee4e0dab
parent 22c26c7a
No related branches found
No related tags found
1 merge request!4954Add support to configure webhook_timeout in gitlab.yaml
Loading
Loading
@@ -497,5 +497,5 @@ GET /projects/search/:query
Parameters:
 
+ query (required) - A string contained in the project name
+ per_page (optional) - number of projects to return per page, defaults to 20
+ offset (optional) - the offset in pages to retrieve
+ per_page (optional) - number of projects to return per page
+ page (optional) - the page to retrieve
Loading
Loading
@@ -266,16 +266,14 @@ module API
#
# Parameters:
# query (required) - A string contained in the project name
# per_page (optional) - number of projects to return per page, defaults to 20
# offset (optional) - the offset in pages to retrieve
# per_page (optional) - number of projects to return per page
# page (optional) - the page to retrieve
# Example Request:
# GET /projects/search/:query
get "/search/:query" do
limit = (params[:per_page] || 20).to_i
offset = (params[:page] || 0).to_i * limit
ids = current_user.authorized_projects.map(&:id)
projects = Project.where("(id in (?) OR public = true) AND (name LIKE (?))", ids, "%#{params[:query]}%").limit(limit).offset(offset)
present projects, with: Entities::Project
projects = Project.where("(id in (?) OR public = true) AND (name LIKE (?))", ids, "%#{params[:query]}%")
present paginate(projects), with: Entities::Project
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment