Class: Gitlab::GithubImport::Importer::PullRequestsReviewsImporter

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

Constant Summary

Constants included from ParallelScheduling

ParallelScheduling::ALREADY_IMPORTED_CACHE_KEY

Instance Attribute Summary

Attributes included from ParallelScheduling

#already_imported_cache_key, #client, #page_counter, #project

Instance Method Summary collapse

Methods included from ParallelScheduling

#abort_on_failure, #already_imported?, #collection_options, #execute, #mark_as_imported, #parallel?, #parallel_import, #parallel_import_batch, #parallel_import_deprecated, #sequential_import, #spread_parallel_import

Constructor Details

#initializePullRequestsReviewsImporter

Returns a new instance of PullRequestsReviewsImporter.


9
10
11
12
13
14
# File 'lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb', line 9

def initialize(...)
  super

  @merge_requests_already_imported_cache_key =
    "github-importer/merge_request/already-imported/#{project.id}"
end

Instance Method Details

#collection_methodObject


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

def collection_method
  :pull_request_reviews
end

#each_object_to_import(&block) ⇒ Object

The worker can be interrupted, by rate limit for instance, in different situations. To avoid requesting already imported data, if the worker is interrupted:

  • before importing all reviews of a merge request The reviews page is cached with the `PageCounter`, by merge request.

  • before importing all merge requests reviews Merge requests that had all the reviews imported are cached with `mark_merge_request_reviews_imported`


48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb', line 48

def each_object_to_import(&block)
  each_review_page do |page, merge_request|
    page.objects.each do |review|
      next if already_imported?(review)

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

      review.merge_request_id = merge_request.id
      yield(review)

      mark_as_imported(review)
    end
  end
end

#id_for_already_imported_cache(review) ⇒ Object


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

def id_for_already_imported_cache(review)
  review.id
end

#importer_classObject


16
17
18
# File 'lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb', line 16

def importer_class
  PullRequestReviewImporter
end

#object_typeObject


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

def object_type
  :pull_request_review
end

#representation_classObject


20
21
22
# File 'lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb', line 20

def representation_class
  Gitlab::GithubImport::Representation::PullRequestReview
end

#sidekiq_worker_classObject


24
25
26
# File 'lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb', line 24

def sidekiq_worker_class
  ImportPullRequestReviewWorker
end