diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/services/jira_connect_subscriptions/create_service.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/services/jira_connect_subscriptions/create_service.rb')
-rw-r--r-- | app/services/jira_connect_subscriptions/create_service.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/services/jira_connect_subscriptions/create_service.rb b/app/services/jira_connect_subscriptions/create_service.rb index 8e794d3acf7..b169d97615d 100644 --- a/app/services/jira_connect_subscriptions/create_service.rb +++ b/app/services/jira_connect_subscriptions/create_service.rb @@ -3,6 +3,8 @@ module JiraConnectSubscriptions class CreateService < ::JiraConnectSubscriptions::BaseService include Gitlab::Utils::StrongMemoize + MERGE_REQUEST_SYNC_BATCH_SIZE = 20 + MERGE_REQUEST_SYNC_BATCH_DELAY = 1.minute.freeze def execute unless namespace && can?(current_user, :create_jira_connect_subscription, namespace) @@ -18,6 +20,8 @@ module JiraConnectSubscriptions subscription = JiraConnectSubscription.new(installation: jira_connect_installation, namespace: namespace) if subscription.save + schedule_sync_project_jobs + success else error(subscription.errors.full_messages.join(', '), 422) @@ -29,5 +33,18 @@ module JiraConnectSubscriptions Namespace.find_by_full_path(params[:namespace_path]) end end + + def schedule_sync_project_jobs + return unless Feature.enabled?(:jira_connect_full_namespace_sync) + + namespace.all_projects.each_batch(of: MERGE_REQUEST_SYNC_BATCH_SIZE) do |projects, index| + JiraConnect::SyncProjectWorker.bulk_perform_in_with_contexts( + index * MERGE_REQUEST_SYNC_BATCH_DELAY, + projects, + arguments_proc: -> (project) { [project.id, Atlassian::JiraConnect::Client.generate_update_sequence_id] }, + context_proc: -> (project) { { project: project } } + ) + end + end end end |