2020-11-11 12:09:06 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module JiraConnect
|
2021-07-09 18:09:51 +00:00
|
|
|
class SyncProjectWorker # rubocop:disable Scalability/IdempotentWorker
|
2020-11-11 12:09:06 +00:00
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-04-30 18:10:09 +00:00
|
|
|
sidekiq_options retry: 3
|
|
|
|
|
2020-11-11 12:09:06 +00:00
|
|
|
queue_namespace :jira_connect
|
|
|
|
feature_category :integrations
|
2021-07-09 18:09:51 +00:00
|
|
|
data_consistency :delayed, feature_flag: :load_balancing_for_jira_connect_workers
|
2021-05-03 09:10:02 +00:00
|
|
|
tags :exclude_from_kubernetes
|
2021-07-09 18:09:51 +00:00
|
|
|
|
2020-11-11 12:09:06 +00:00
|
|
|
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
|