blob: 07ee9569ab11099570d521149181e4225bedce3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# frozen_string_literal: true
module Gitlab
module BitbucketServerImport
module Importers
class NotesImporter
include ParallelScheduling
def execute
project.merge_requests.find_each do |merge_request|
# Needs to come before `already_processed?` as `jobs_remaining` resets to zero when the job restarts and
# jobs_remaining needs to be the total amount of enqueued jobs
job_waiter.jobs_remaining += 1
next if already_processed?(merge_request)
job_delay = calculate_job_delay(job_waiter.jobs_remaining)
sidekiq_worker_class.perform_in(job_delay, project.id, { iid: merge_request.iid }, job_waiter.key)
mark_as_processed(merge_request)
end
job_waiter
end
private
attr_reader :project
def sidekiq_worker_class
ImportPullRequestNotesWorker
end
def id_for_already_processed_cache(merge_request)
merge_request.iid
end
def collection_method
:notes
end
end
end
end
end
|