Module: Gitlab::GithubImport::StageMethods
- Included in:
- Gitlab::GithubImport::Stage::FinishImportWorker, Gitlab::GithubImport::Stage::ImportAttachmentsWorker, Gitlab::GithubImport::Stage::ImportBaseDataWorker, Gitlab::GithubImport::Stage::ImportCollaboratorsWorker, Gitlab::GithubImport::Stage::ImportIssueEventsWorker, Gitlab::GithubImport::Stage::ImportIssuesAndDiffNotesWorker, Gitlab::GithubImport::Stage::ImportLfsObjectsWorker, Gitlab::GithubImport::Stage::ImportNotesWorker, Gitlab::GithubImport::Stage::ImportProtectedBranchesWorker, Gitlab::GithubImport::Stage::ImportPullRequestsMergedByWorker, Gitlab::GithubImport::Stage::ImportPullRequestsReviewRequestsWorker, Gitlab::GithubImport::Stage::ImportPullRequestsReviewsWorker, Gitlab::GithubImport::Stage::ImportPullRequestsWorker, Gitlab::GithubImport::Stage::ImportRepositoryWorker
- Defined in:
- app/workers/concerns/gitlab/github_import/stage_methods.rb
Instance Method Summary collapse
- #abort_on_failure ⇒ Object
- #find_project(id) ⇒ Object
-
#perform(project_id) ⇒ Object
project_id - The ID of the GitLab project to import the data into.
-
#try_import(client, project) ⇒ Object
client - An instance of Gitlab::GithubImport::Client.
Instance Method Details
#abort_on_failure ⇒ Object
54 55 56 |
# File 'app/workers/concerns/gitlab/github_import/stage_methods.rb', line 54 def abort_on_failure false end |
#find_project(id) ⇒ Object
46 47 48 49 50 51 52 |
# File 'app/workers/concerns/gitlab/github_import/stage_methods.rb', line 46 def find_project(id) # If the project has been marked as failed we want to bail out # automatically. # rubocop: disable CodeReuse/ActiveRecord Project.joins_import_state.where(import_state: { status: :started }).find_by_id(id) # rubocop: enable CodeReuse/ActiveRecord end |
#perform(project_id) ⇒ Object
project_id - The ID of the GitLab project to import the data into.
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 |
# File 'app/workers/concerns/gitlab/github_import/stage_methods.rb', line 7 def perform(project_id) info(project_id, message: 'starting stage') return unless (project = find_project(project_id)) if project.import_state&.completed? info( project_id, message: 'Project import is no longer running. Stopping worker.', import_status: project.import_state.status ) return end client = GithubImport.new_client_for(project) try_import(client, project) info(project_id, message: 'stage finished') rescue StandardError => e Gitlab::Import::ImportFailureService.track( project_id: project_id, exception: e, error_source: self.class.name, fail_import: abort_on_failure ) raise(e) end |
#try_import(client, project) ⇒ Object
client - An instance of Gitlab::GithubImport::Client. project - An instance of Project.
40 41 42 43 44 |
# File 'app/workers/concerns/gitlab/github_import/stage_methods.rb', line 40 def try_import(client, project) import(client, project) rescue RateLimitError self.class.perform_in(client.rate_limit_resets_in, project.id) end |