summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2015-12-28 13:33:03 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2015-12-28 13:33:35 +0100
commitf4cff4dcd0b11d4597efe454731838fbf5803516 (patch)
treed150ec0e680e836fed6c735e8cbd62de019ee3d3 /lib
parentf39959d00a1358ba7d73ebeaccb827738c8151ba (diff)
downloadgitlab-ce-f4cff4dcd0b11d4597efe454731838fbf5803516.tar.gz
Modify build pagination to use 'paginate' helper
Diffstat (limited to 'lib')
-rw-r--r--lib/api/builds.rb5
-rw-r--r--lib/api/helpers.rb6
2 files changed, 5 insertions, 6 deletions
diff --git a/lib/api/builds.rb b/lib/api/builds.rb
index 863be0d5e40..f219b0f5241 100644
--- a/lib/api/builds.rb
+++ b/lib/api/builds.rb
@@ -26,10 +26,7 @@ module API
builds
end
- page = (params[:page] || 1).to_i
- per_page = (params[:per_page] || 30).to_i
-
- present builds.page(page).per(per_page), with: Entities::Build
+ present paginate(builds), with: Entities::Build
end
# Get a specific build of a project
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index a4df810e755..8fb5cd6ab63 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -97,8 +97,10 @@ module API
end
def paginate(relation)
- per_page = params[:per_page].to_i
- paginated = relation.page(params[:page]).per(per_page)
+ page = (params[:page] || 1).to_i
+ per_page = (params[:per_page] || 30).to_i
+
+ paginated = relation.page(page).per(per_page)
add_pagination_headers(paginated, per_page)
paginated