Class: Gitlab::BitbucketImport::Importers::PullRequestsImporter

Inherits:
Object
  • Object
show all
Includes:
ParallelScheduling
Defined in:
lib/gitlab/bitbucket_import/importers/pull_requests_importer.rb

Constant Summary

Constants included from ParallelScheduling

ParallelScheduling::ALREADY_ENQUEUED_CACHE_KEY, ParallelScheduling::BATCH_SIZE, ParallelScheduling::JOB_WAITER_CACHE_KEY

Instance Attribute Summary

Attributes included from ParallelScheduling

#already_enqueued_cache_key, #job_waiter_cache_key, #project

Instance Method Summary collapse

Methods included from ParallelScheduling

#initialize

Methods included from ErrorTracking

#track_import_failure!

Methods included from Loggable

#log_debug, #log_error, #log_info, #log_warn

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/bitbucket_import/importers/pull_requests_importer.rb', line 9

def execute
  log_info(import_stage: 'import_pull_requests', message: 'importing pull requests')

  pull_requests = client.pull_requests(project.import_source)

  pull_requests.each do |pull_request|
    job_waiter.jobs_remaining += 1

    next if already_enqueued?(pull_request)

    job_delay = calculate_job_delay(job_waiter.jobs_remaining)

    sidekiq_worker_class.perform_in(job_delay, project.id, pull_request.to_hash, job_waiter.key)

    mark_as_enqueued(pull_request)
  end

  job_waiter
rescue StandardError => e
  track_import_failure!(project, exception: e)
end