Class: Gitlab::GithubImport::Importer::Attachments::BaseImporter

Inherits:
Object
  • Object
show all
Includes:
ParallelScheduling
Defined in:
lib/gitlab/github_import/importer/attachments/base_importer.rb

Constant Summary collapse

BATCH_SIZE =
100

Constants included from ParallelScheduling

ParallelScheduling::ALREADY_IMPORTED_CACHE_KEY, ParallelScheduling::JOB_WAITER_CACHE_KEY, ParallelScheduling::JOB_WAITER_REMAINING_CACHE_KEY

Instance Attribute Summary

Attributes included from ParallelScheduling

#already_imported_cache_key, #client, #job_waiter_cache_key, #job_waiter_remaining_cache_key, #page_counter, #project

Instance Method Summary collapse

Methods included from ParallelScheduling

#abort_on_failure, #already_imported?, #collection_method, #collection_options, #execute, #id_for_already_imported_cache, #increment_object_counter?, #initialize, #mark_as_imported, #object_type, #parallel?, #parallel_import, #sequential_import, #sidekiq_worker_class, #spread_parallel_import

Methods included from JobDelayCalculator

#parallel_import_batch

Instance Method Details

#each_object_to_importObject

The method that will be called for traversing through all the objects to import, yielding them to the supplied block.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitlab/github_import/importer/attachments/base_importer.rb', line 14

def each_object_to_import
  collection.each_batch(of: BATCH_SIZE, column: ordering_column) do |batch|
    batch.each do |record|
      next if already_imported?(record)

      Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :fetched)

      yield record

      # We mark the object as imported immediately so we don't end up
      # scheduling it multiple times.
      mark_as_imported(record)
    end
  end
end

#importer_classObject



34
35
36
# File 'lib/gitlab/github_import/importer/attachments/base_importer.rb', line 34

def importer_class
  NoteAttachmentsImporter
end

#representation_classObject



30
31
32
# File 'lib/gitlab/github_import/importer/attachments/base_importer.rb', line 30

def representation_class
  Representation::NoteText
end