diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-12-07 17:59:08 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-12-07 17:59:08 +0300 |
commit | b081614befa3d548e409c8a87bca34de652a9042 (patch) | |
tree | f28c090523858151148e197e0731b60943dc14c9 | |
parent | 6173727a36dfe4ea99f8e2794d0280d515ddbb53 (diff) | |
parent | b2cf4b9525f41b2de7c96c493d0fe296760a736b (diff) |
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
-rw-r--r-- | lib/api/namespaces.rb | 17 | ||||
-rw-r--r-- | lib/gitlab/database/migration_helpers.rb | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/api/namespaces.rb b/lib/api/namespaces.rb index 06a57e3cd6f..3cc09f6ac3f 100644 --- a/lib/api/namespaces.rb +++ b/lib/api/namespaces.rb @@ -6,20 +6,35 @@ module API 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 desc 'Get a namespaces list' do success Entities::Namespace end params do optional :search, type: String, desc: "Search query for namespaces" + use :pagination + use :optional_list_params_ee end get do namespaces = current_user.admin ? Namespace.all : current_user.namespaces 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 desc 'Get a namespace by ID' do diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index 134d1e7a724..d9578852db6 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -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') jobs = [] + table_name = model_class.quoted_table_name 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 # Note: This code path generally only helps with many millions of rows |