summaryrefslogtreecommitdiff
path: root/lib/api/templates.rb
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2017-01-17 05:45:07 +0100
committerRobert Schilling <rschilling@student.tugraz.at>2017-02-16 15:32:01 +0100
commit01ea65e0e9ea5e44fa653fb95e7ba8ca1668af98 (patch)
treeb7360600a01fff3a1e47a4d8c4f00b42d81fe836 /lib/api/templates.rb
parent28d8b8650759d0032bcfd0fd9b4397d139a43984 (diff)
downloadgitlab-ce-01ea65e0e9ea5e44fa653fb95e7ba8ca1668af98.tar.gz
Paginate all endpoints that return an array
Diffstat (limited to 'lib/api/templates.rb')
-rw-r--r--lib/api/templates.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/api/templates.rb b/lib/api/templates.rb
index 8a2d66efd89..2fcfe3d75c8 100644
--- a/lib/api/templates.rb
+++ b/lib/api/templates.rb
@@ -1,5 +1,7 @@
module API
class Templates < Grape::API
+ include PaginationParams
+
GLOBAL_TEMPLATE_TYPES = {
gitignores: {
klass: Gitlab::Template::GitignoreTemplate,
@@ -51,12 +53,14 @@ module API
end
params do
optional :popular, type: Boolean, desc: 'If passed, returns only popular licenses'
+ use :pagination
end
get "templates/licenses" do
options = {
featured: declared(params).popular.present? ? true : nil
}
- present Licensee::License.all(options), with: ::API::Entities::RepoLicense
+ licences = ::Kaminari.paginate_array(Licensee::License.all(options))
+ present paginate(licences), with: Entities::RepoLicense
end
desc 'Get the text for a specific license' do
@@ -82,8 +86,12 @@ module API
detail "This feature was introduced in GitLab #{gitlab_version}."
success Entities::TemplatesList
end
+ params do
+ use :pagination
+ end
get "templates/#{template_type}" do
- present klass.all, with: Entities::TemplatesList
+ templates = ::Kaminari.paginate_array(klass.all)
+ present paginate(templates), with: Entities::TemplatesLis
end
desc 'Get the text for a specific template present in local filesystem' do