diff options
Diffstat (limited to 'app/services/git/branch_hooks_service.rb')
-rw-r--r-- | app/services/git/branch_hooks_service.rb | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/app/services/git/branch_hooks_service.rb b/app/services/git/branch_hooks_service.rb index 2ead2e2a113..31da099d078 100644 --- a/app/services/git/branch_hooks_service.rb +++ b/app/services/git/branch_hooks_service.rb @@ -4,6 +4,9 @@ module Git class BranchHooksService < ::Git::BaseHooksService extend ::Gitlab::Utils::Override + JIRA_SYNC_BATCH_SIZE = 20 + JIRA_SYNC_BATCH_DELAY = 10.seconds + def execute execute_branch_hooks @@ -99,7 +102,6 @@ module Git def branch_change_hooks enqueue_process_commit_messages enqueue_jira_connect_sync_messages - enqueue_metrics_dashboard_sync track_ci_config_change_event end @@ -107,13 +109,6 @@ module Git project.repository.after_remove_branch(expire_cache: false) end - def enqueue_metrics_dashboard_sync - return unless default_branch? - return unless modified_file_types.include?(:metrics_dashboard) - - ::Metrics::Dashboard::SyncDashboardsWorker.perform_async(project.id) - end - def track_ci_config_change_event return unless ::ServicePing::ServicePingSettings.enabled? return unless default_branch? @@ -157,13 +152,34 @@ module Git return unless project.jira_subscription_exists? branch_to_sync = branch_name if Atlassian::JiraIssueKeyExtractors::Branch.has_keys?(project, branch_name) - commits_to_sync = limited_commits.select { |commit| Atlassian::JiraIssueKeyExtractor.has_keys?(commit.safe_message) }.map(&:sha) - - if branch_to_sync || commits_to_sync.any? - JiraConnect::SyncBranchWorker.perform_async(project.id, branch_to_sync, commits_to_sync, Atlassian::JiraConnect::Client.generate_update_sequence_id) + commits_to_sync = filtered_commit_shas + + return if branch_to_sync.nil? && commits_to_sync.empty? + + if commits_to_sync.any? && Feature.enabled?(:batch_delay_jira_branch_sync_worker, project) + commits_to_sync.each_slice(JIRA_SYNC_BATCH_SIZE).with_index do |commits, i| + JiraConnect::SyncBranchWorker.perform_in( + JIRA_SYNC_BATCH_DELAY * i, + project.id, + branch_to_sync, + commits, + Atlassian::JiraConnect::Client.generate_update_sequence_id + ) + end + else + JiraConnect::SyncBranchWorker.perform_async( + project.id, + branch_to_sync, + commits_to_sync, + Atlassian::JiraConnect::Client.generate_update_sequence_id + ) end end + def filtered_commit_shas + limited_commits.select { |commit| Atlassian::JiraIssueKeyExtractor.has_keys?(commit.safe_message) }.map(&:sha) + end + def signature_types [ ::CommitSignatures::GpgSignature, |