Commit b081614b authored by Douwe Maan's avatar Douwe Maan

Merge branch '7772-add-subscription-table-to-gitlab-com-billing-areas-ce' into 'master'

Backports some changes from gitlab-ee!7885

See merge request gitlab-org/gitlab-ce!23637
parents 6173727a b2cf4b95
...@@ -6,20 +6,35 @@ module API ...@@ -6,20 +6,35 @@ module API
before { authenticate! } before { authenticate! }
helpers do
params :optional_list_params_ee do
# EE::API::Namespaces would override this helper
end
# EE::API::Namespaces would override this method
def custom_namespace_present_options
{}
end
end
resource :namespaces do resource :namespaces do
desc 'Get a namespaces list' do desc 'Get a namespaces list' do
success Entities::Namespace success Entities::Namespace
end end
params do params do
optional :search, type: String, desc: "Search query for namespaces" optional :search, type: String, desc: "Search query for namespaces"
use :pagination use :pagination
use :optional_list_params_ee
end end
get do get do
namespaces = current_user.admin ? Namespace.all : current_user.namespaces namespaces = current_user.admin ? Namespace.all : current_user.namespaces
namespaces = namespaces.search(params[:search]) if params[:search].present? namespaces = namespaces.search(params[:search]) if params[:search].present?
present paginate(namespaces), with: Entities::Namespace, current_user: current_user options = { with: Entities::Namespace, current_user: current_user }
present paginate(namespaces), options.reverse_merge(custom_namespace_present_options)
end end
desc 'Get a namespace by ID' do desc 'Get a namespace by ID' do
......
...@@ -975,9 +975,10 @@ into similar problems in the future (e.g. when new tables are created). ...@@ -975,9 +975,10 @@ into similar problems in the future (e.g. when new tables are created).
raise "#{model_class} does not have an ID to use for batch ranges" unless model_class.column_names.include?('id') raise "#{model_class} does not have an ID to use for batch ranges" unless model_class.column_names.include?('id')
jobs = [] jobs = []
table_name = model_class.quoted_table_name
model_class.each_batch(of: batch_size) do |relation| model_class.each_batch(of: batch_size) do |relation|
start_id, end_id = relation.pluck('MIN(id), MAX(id)').first start_id, end_id = relation.pluck("MIN(#{table_name}.id), MAX(#{table_name}.id)").first
if jobs.length >= BACKGROUND_MIGRATION_JOB_BUFFER_SIZE if jobs.length >= BACKGROUND_MIGRATION_JOB_BUFFER_SIZE
# Note: This code path generally only helps with many millions of rows # Note: This code path generally only helps with many millions of rows
......
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