Commit 76e4d94d432b19d7dd58503c5eac46811630c04a
1 parent
6817a6a2
Exists in
master
and in
4 other branches
add pagination to API
Showing
6 changed files
with
16 additions
and
5 deletions
Show diff stats
doc/api/README.md
| ... | ... | @@ -23,6 +23,13 @@ GET http://example.com/api/v2/projects?private_token=QVy1PB7sTxfy4pqfZM1U |
| 23 | 23 | |
| 24 | 24 | The API uses JSON to serialize data. You don't need to specify `.json` at the end of API URL. |
| 25 | 25 | |
| 26 | +#### Pagination | |
| 27 | + | |
| 28 | +When listing resources you can pass the following parameters: | |
| 29 | + | |
| 30 | ++ `page` (default: `1`) - page number | |
| 31 | ++ `per_page` (default: `20`, max: `100`) - how many items to list per page | |
| 32 | + | |
| 26 | 33 | ## Contents |
| 27 | 34 | |
| 28 | 35 | + [Users](https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/users.md) | ... | ... |
lib/api/helpers.rb
lib/api/issues.rb
| ... | ... | @@ -9,7 +9,7 @@ module Gitlab |
| 9 | 9 | # Example Request: |
| 10 | 10 | # GET /issues |
| 11 | 11 | get do |
| 12 | - present current_user.issues, with: Entities::Issue | |
| 12 | + present paginate(current_user.issues), with: Entities::Issue | |
| 13 | 13 | end |
| 14 | 14 | end |
| 15 | 15 | |
| ... | ... | @@ -21,7 +21,7 @@ module Gitlab |
| 21 | 21 | # Example Request: |
| 22 | 22 | # GET /projects/:id/issues |
| 23 | 23 | get ":id/issues" do |
| 24 | - present user_project.issues, with: Entities::Issue | |
| 24 | + present paginate(user_project.issues), with: Entities::Issue | |
| 25 | 25 | end |
| 26 | 26 | |
| 27 | 27 | # Get a single project issue | ... | ... |
lib/api/milestones.rb
| ... | ... | @@ -11,7 +11,7 @@ module Gitlab |
| 11 | 11 | # Example Request: |
| 12 | 12 | # GET /projects/:id/milestones |
| 13 | 13 | get ":id/milestones" do |
| 14 | - present user_project.milestones, with: Entities::Milestone | |
| 14 | + present paginate(user_project.milestones), with: Entities::Milestone | |
| 15 | 15 | end |
| 16 | 16 | |
| 17 | 17 | # Get a single project milestone | ... | ... |
lib/api/projects.rb