diff options
Diffstat (limited to 'app/workers/jira_connect')
-rw-r--r-- | app/workers/jira_connect/sync_branch_worker.rb | 4 | ||||
-rw-r--r-- | app/workers/jira_connect/sync_merge_request_worker.rb | 4 | ||||
-rw-r--r-- | app/workers/jira_connect/sync_project_worker.rb | 30 |
3 files changed, 34 insertions, 4 deletions
diff --git a/app/workers/jira_connect/sync_branch_worker.rb b/app/workers/jira_connect/sync_branch_worker.rb index 8c3416478fd..4c1c987353d 100644 --- a/app/workers/jira_connect/sync_branch_worker.rb +++ b/app/workers/jira_connect/sync_branch_worker.rb @@ -8,7 +8,7 @@ module JiraConnect feature_category :integrations loggable_arguments 1, 2 - def perform(project_id, branch_name, commit_shas) + def perform(project_id, branch_name, commit_shas, update_sequence_id = nil) project = Project.find_by_id(project_id) return unless project @@ -16,7 +16,7 @@ module JiraConnect branches = [project.repository.find_branch(branch_name)] if branch_name.present? commits = project.commits_by(oids: commit_shas) if commit_shas.present? - JiraConnect::SyncService.new(project).execute(commits: commits, branches: branches) + JiraConnect::SyncService.new(project).execute(commits: commits, branches: branches, update_sequence_id: update_sequence_id) end end end diff --git a/app/workers/jira_connect/sync_merge_request_worker.rb b/app/workers/jira_connect/sync_merge_request_worker.rb index b78bb8dfe16..f45ab38f35d 100644 --- a/app/workers/jira_connect/sync_merge_request_worker.rb +++ b/app/workers/jira_connect/sync_merge_request_worker.rb @@ -7,12 +7,12 @@ module JiraConnect queue_namespace :jira_connect feature_category :integrations - def perform(merge_request_id) + def perform(merge_request_id, update_sequence_id = nil) merge_request = MergeRequest.find_by_id(merge_request_id) return unless merge_request && merge_request.project - JiraConnect::SyncService.new(merge_request.project).execute(merge_requests: [merge_request]) + JiraConnect::SyncService.new(merge_request.project).execute(merge_requests: [merge_request], update_sequence_id: update_sequence_id) end end end diff --git a/app/workers/jira_connect/sync_project_worker.rb b/app/workers/jira_connect/sync_project_worker.rb new file mode 100644 index 00000000000..4d52705f207 --- /dev/null +++ b/app/workers/jira_connect/sync_project_worker.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module JiraConnect + class SyncProjectWorker + include ApplicationWorker + + queue_namespace :jira_connect + feature_category :integrations + idempotent! + worker_has_external_dependencies! + + MERGE_REQUEST_LIMIT = 400 + + def perform(project_id, update_sequence_id) + project = Project.find_by_id(project_id) + + return if project.nil? + + JiraConnect::SyncService.new(project).execute(merge_requests: merge_requests_to_sync(project), update_sequence_id: update_sequence_id) + end + + private + + # rubocop: disable CodeReuse/ActiveRecord + def merge_requests_to_sync(project) + project.merge_requests.with_jira_issue_keys.preload(:author).limit(MERGE_REQUEST_LIMIT).order(id: :desc) + end + # rubocop: enable CodeReuse/ActiveRecord + end +end |