diff options
author | Izaak Alpert <ialpert@blackberry.com> | 2013-09-24 09:22:46 -0400 |
---|---|---|
committer | Izaak Alpert <ialpert@blackberry.com> | 2013-09-24 09:22:46 -0400 |
commit | 04c7c262a7be469a4ae4865464b003c4b522a895 (patch) | |
tree | 8f759018d3df7a810deb5b5e646ce2afe763b6fd /lib/api/projects.rb | |
parent | 9d06921ffb2082cdcb6bcce3e420d53011a3b71d (diff) | |
download | gitlab-ce-04c7c262a7be469a4ae4865464b003c4b522a895.tar.gz |
Used pagnation function from api helpers
Change-Id: I1bdd3608d3b46924b5da3ae282c99f85ee4e0dab
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index d17b791dccc..cf357b23c40 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -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 |