Class: Gitlab::GithubImport::Importer::CollaboratorsImporter

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

Constant Summary

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_options, #execute, #increment_object_counter?, #initialize, #mark_as_imported, #parallel?, #parallel_import, #sequential_import, #spread_parallel_import

Methods included from JobDelayCalculator

#parallel_import_batch

Instance Method Details

#collection_methodObject



44
45
46
# File 'lib/gitlab/github_import/importer/collaborators_importer.rb', line 44

def collection_method
  :collaborators
end

#each_object_to_importObject

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



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/github_import/importer/collaborators_importer.rb', line 11

def each_object_to_import
  repo = project.import_source

  direct_collaborators = client.collaborators(repo, affiliation: 'direct')
  outside_collaborators = client.collaborators(repo, affiliation: 'outside')
  collaborators_to_import = direct_collaborators.to_a - outside_collaborators.to_a

  collaborators_to_import.each do |collaborator|
    next if already_imported?(collaborator)

    yield collaborator

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

#id_for_already_imported_cache(collaborator) ⇒ Object



48
49
50
# File 'lib/gitlab/github_import/importer/collaborators_importer.rb', line 48

def id_for_already_imported_cache(collaborator)
  collaborator[:id]
end

#importer_classObject



28
29
30
# File 'lib/gitlab/github_import/importer/collaborators_importer.rb', line 28

def importer_class
  CollaboratorImporter
end

#object_typeObject



40
41
42
# File 'lib/gitlab/github_import/importer/collaborators_importer.rb', line 40

def object_type
  :collaborator
end

#representation_classObject



32
33
34
# File 'lib/gitlab/github_import/importer/collaborators_importer.rb', line 32

def representation_class
  Representation::Collaborator
end

#sidekiq_worker_classObject



36
37
38
# File 'lib/gitlab/github_import/importer/collaborators_importer.rb', line 36

def sidekiq_worker_class
  ImportCollaboratorWorker
end