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/workers/jira_connect/sync_project_worker.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/workers/jira_connect/sync_project_worker.rb')
-rw-r--r-- | app/workers/jira_connect/sync_project_worker.rb | 30 |
1 files changed, 30 insertions, 0 deletions
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 |