Commit f4cff4dc authored by Tomasz Maczukin's avatar Tomasz Maczukin

Modify build pagination to use 'paginate' helper

parent f39959d0
...@@ -26,10 +26,7 @@ module API ...@@ -26,10 +26,7 @@ module API
builds builds
end end
page = (params[:page] || 1).to_i present paginate(builds), with: Entities::Build
per_page = (params[:per_page] || 30).to_i
present builds.page(page).per(per_page), with: Entities::Build
end end
# Get a specific build of a project # Get a specific build of a project
......
...@@ -97,8 +97,10 @@ module API ...@@ -97,8 +97,10 @@ module API
end end
def paginate(relation) def paginate(relation)
per_page = params[:per_page].to_i page = (params[:page] || 1).to_i
paginated = relation.page(params[:page]).per(per_page) per_page = (params[:per_page] || 30).to_i
paginated = relation.page(page).per(per_page)
add_pagination_headers(paginated, per_page) add_pagination_headers(paginated, per_page)
paginated paginated
......
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