Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-29 21:06:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-29 21:06:24 +0300
commit8263f6ee3131cdea3c6041785c32771a6af0b24f (patch)
tree3dde0ed2466b10fa223eacbd51c78beb32009fbd /lib/api
parenteac0da9a47f0c7b8b970833d7d5b96cfee057bf7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/helpers/pagination.rb16
-rw-r--r--lib/api/projects.rb6
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/api/helpers/pagination.rb b/lib/api/helpers/pagination.rb
index 9c5b355e823..642053949d9 100644
--- a/lib/api/helpers/pagination.rb
+++ b/lib/api/helpers/pagination.rb
@@ -4,7 +4,21 @@ module API
module Helpers
module Pagination
def paginate(relation)
- ::Gitlab::Pagination::OffsetPagination.new(self).paginate(relation)
+ return Gitlab::Pagination::OffsetPagination.new(self).paginate(relation) unless keyset_pagination_enabled?
+
+ request_context = Gitlab::Pagination::Keyset::RequestContext.new(self)
+
+ unless Gitlab::Pagination::Keyset.available?(request_context, relation)
+ return error!('Keyset pagination is not yet available for this type of request', 501)
+ end
+
+ Gitlab::Pagination::Keyset.paginate(request_context, relation)
+ end
+
+ private
+
+ def keyset_pagination_enabled?
+ params[:pagination] == 'keyset' && Feature.enabled?(:api_keyset_pagination)
end
end
end
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index a1fce9e8b20..666bd2771f9 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -82,7 +82,6 @@ module API
def present_projects(projects, options = {})
projects = reorder_projects(projects)
projects = apply_filters(projects)
- projects = paginate(projects)
projects, options = with_custom_attributes(projects, options)
options = options.reverse_merge(
@@ -93,7 +92,10 @@ module API
)
options[:with] = Entities::BasicProjectDetails if params[:simple]
- present options[:with].prepare_relation(projects, options), options
+ projects = options[:with].prepare_relation(projects, options)
+ projects = paginate(projects)
+
+ present projects, options
end
def translate_params_for_compatibility(params)