blob: 417b85985479e366e7dbda17d2d5873bdead4caf (
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
46
47
48
49
50
51
52
53
54
|
# frozen_string_literal: true
module Gitlab
module GithubImport
# AdvanceStageWorker is a worker used by the GitHub importer to wait for a
# number of jobs to complete, without blocking a thread. Once all jobs have
# been completed this worker will advance the import process to the next
# stage.
class AdvanceStageWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
data_consistency :always
include ::Gitlab::Import::AdvanceStage
loggable_arguments 1, 2
sidekiq_options retry: 6
# TODO: Allow this class to include GithubImport::Queue and remove
# the following two lines https://gitlab.com/gitlab-org/gitlab/-/issues/435622
feature_category :importers
sidekiq_options dead: false
# The known importer stages and their corresponding Sidekiq workers.
STAGES = {
collaborators: Stage::ImportCollaboratorsWorker,
pull_requests_merged_by: Stage::ImportPullRequestsMergedByWorker,
pull_request_review_requests: Stage::ImportPullRequestsReviewRequestsWorker,
pull_request_reviews: Stage::ImportPullRequestsReviewsWorker,
issues_and_diff_notes: Stage::ImportIssuesAndDiffNotesWorker,
issue_events: Stage::ImportIssueEventsWorker,
notes: Stage::ImportNotesWorker,
attachments: Stage::ImportAttachmentsWorker,
protected_branches: Stage::ImportProtectedBranchesWorker,
lfs_objects: Stage::ImportLfsObjectsWorker,
finish: Stage::FinishImportWorker
}.freeze
def find_import_state_jid(project_id)
ProjectImportState.jid_by(project_id: project_id, status: :started)
end
def find_import_state(id)
ProjectImportState.find(id)
end
private
def next_stage_worker(next_stage)
STAGES.fetch(next_stage.to_sym)
end
end
end
end
|