summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/api/branches.rb11
-rw-r--r--lib/api/milestone_responses.rb29
-rw-r--r--lib/api/project_milestones.rb2
-rw-r--r--lib/gitlab/git/repository.rb4
-rw-r--r--lib/gitlab/gitaly_client/ref_service.rb4
-rw-r--r--lib/gitlab/sidekiq_versioning.rb4
-rw-r--r--lib/gitlab/sidekiq_versioning/middleware.rb13
-rw-r--r--lib/gitlab/sidekiq_versioning/worker.rb31
8 files changed, 17 insertions, 81 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb
index bbed50e96ea..5e9c2caf8f5 100644
--- a/lib/api/branches.rb
+++ b/lib/api/branches.rb
@@ -32,14 +32,21 @@ module API
params do
use :pagination
use :filter_params
+
+ optional :page_token, type: String, desc: 'Name of branch to start the paginaition from'
end
get ':id/repository/branches' do
user_project.preload_protected_branches
repository = user_project.repository
- branches = BranchesFinder.new(repository, declared_params(include_missing: false)).execute
- branches = paginate(::Kaminari.paginate_array(branches))
+ if Feature.enabled?(:branch_list_keyset_pagination, user_project)
+ branches = BranchesFinder.new(repository, declared_params(include_missing: false)).execute(gitaly_pagination: true)
+ else
+ branches = BranchesFinder.new(repository, declared_params(include_missing: false)).execute
+ branches = paginate(::Kaminari.paginate_array(branches))
+ end
+
merged_branch_names = repository.merged_branch_names(branches.map(&:name))
present(
diff --git a/lib/api/milestone_responses.rb b/lib/api/milestone_responses.rb
index ec108ea8c83..8ff885983bc 100644
--- a/lib/api/milestone_responses.rb
+++ b/lib/api/milestone_responses.rb
@@ -31,14 +31,12 @@ module API
end
def list_milestones_for(parent)
- finder_params = params.merge(milestones_finder_params(parent))
- milestones = MilestonesFinder.new(finder_params).execute
+ milestones = parent.milestones.order_id_desc
+ milestones = Milestone.filter_by_state(milestones, params[:state])
+ milestones = filter_by_iid(milestones, params[:iids]) if params[:iids].present?
+ milestones = filter_by_title(milestones, params[:title]) if params[:title]
milestones = filter_by_search(milestones, params[:search]) if params[:search]
- if params[:iids].present? && !params[:include_parent_milestones]
- milestones = filter_by_iid(milestones, params[:iids])
- end
-
present paginate(milestones), with: Entities::Milestone
end
@@ -98,25 +96,6 @@ module API
[MergeRequestsFinder, Entities::MergeRequestBasic]
end
end
-
- def milestones_finder_params(parent)
- if parent.is_a?(Group)
- { group_ids: parent.id }
- else
- {
- project_ids: parent.id,
- group_ids: parent_group_ids(parent)
- }
- end
- end
-
- def parent_group_ids(parent)
- return unless params[:include_parent_milestones].present?
-
- parent.group.self_and_ancestors
- .public_or_visible_to_user(current_user)
- .select(:id)
- end
end
end
end
diff --git a/lib/api/project_milestones.rb b/lib/api/project_milestones.rb
index ef74e8cb0c9..2f8dd1085dc 100644
--- a/lib/api/project_milestones.rb
+++ b/lib/api/project_milestones.rb
@@ -16,8 +16,6 @@ module API
end
params do
use :list_params
- optional :include_parent_milestones, type: Boolean, default: false,
- desc: 'Include milestones from parent group and ancestors'
end
get ":id/milestones" do
authorize! :read_milestone, user_project
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index a1095ff9a86..ea7a6e84195 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -127,9 +127,9 @@ module Gitlab
end
end
- def local_branches(sort_by: nil)
+ def local_branches(sort_by: nil, pagination_params: nil)
wrapped_gitaly_errors do
- gitaly_ref_client.local_branches(sort_by: sort_by)
+ gitaly_ref_client.local_branches(sort_by: sort_by, pagination_params: pagination_params)
end
end
diff --git a/lib/gitlab/gitaly_client/ref_service.rb b/lib/gitlab/gitaly_client/ref_service.rb
index e0ccc13234a..97b6813c080 100644
--- a/lib/gitlab/gitaly_client/ref_service.rb
+++ b/lib/gitlab/gitaly_client/ref_service.rb
@@ -110,8 +110,8 @@ module Gitlab
branch_names.count
end
- def local_branches(sort_by: nil)
- request = Gitaly::FindLocalBranchesRequest.new(repository: @gitaly_repo)
+ def local_branches(sort_by: nil, pagination_params: nil)
+ request = Gitaly::FindLocalBranchesRequest.new(repository: @gitaly_repo, pagination_params: pagination_params)
request.sort_by = sort_by_param(sort_by) if sort_by
response = GitalyClient.call(@storage, :ref_service, :find_local_branches, request, timeout: GitalyClient.fast_timeout)
consume_find_local_branches_response(response)
diff --git a/lib/gitlab/sidekiq_versioning.rb b/lib/gitlab/sidekiq_versioning.rb
index 0b0e090630a..8164a5a9d7a 100644
--- a/lib/gitlab/sidekiq_versioning.rb
+++ b/lib/gitlab/sidekiq_versioning.rb
@@ -5,10 +5,6 @@ module Gitlab
def self.install!
Sidekiq::Manager.prepend SidekiqVersioning::Manager
- Sidekiq.server_middleware do |chain|
- chain.add SidekiqVersioning::Middleware
- end
-
# The Sidekiq client API always adds the queue to the Sidekiq queue
# list, but mail_room and gitlab-shell do not. This is only necessary
# for monitoring.
diff --git a/lib/gitlab/sidekiq_versioning/middleware.rb b/lib/gitlab/sidekiq_versioning/middleware.rb
deleted file mode 100644
index e5aa40722d2..00000000000
--- a/lib/gitlab/sidekiq_versioning/middleware.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module SidekiqVersioning
- class Middleware
- def call(worker, job, queue)
- worker.job_version = job['version']
-
- yield
- end
- end
- end
-end
diff --git a/lib/gitlab/sidekiq_versioning/worker.rb b/lib/gitlab/sidekiq_versioning/worker.rb
deleted file mode 100644
index fe9bae6b8a1..00000000000
--- a/lib/gitlab/sidekiq_versioning/worker.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module SidekiqVersioning
- module Worker
- extend ActiveSupport::Concern
-
- included do
- version 0
-
- attr_writer :job_version
- end
-
- class_methods do
- def version(new_version = nil)
- if new_version
- sidekiq_options version: new_version.to_i
- else
- get_sidekiq_options['version']
- end
- end
- end
-
- # Version is not set if `new.perform` is called directly,
- # and in that case we fallback to latest version
- def job_version
- @job_version ||= self.class.version
- end
- end
- end
-end