diff options
Diffstat (limited to 'lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb')
-rw-r--r-- | lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb b/lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb index e389acbf877..bd65eb5899c 100644 --- a/lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb +++ b/lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb @@ -37,43 +37,6 @@ module Gitlab review.id end - def each_object_to_import(&block) - if use_github_review_importer_query_only_unimported_merge_requests? - each_merge_request_to_import(&block) - else - each_merge_request_skipping_imported(&block) - end - end - - private - - attr_reader :merge_requests_already_imported_cache_key - - # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62036#note_587181108 - def use_github_review_importer_query_only_unimported_merge_requests? - Feature.enabled?( - :github_review_importer_query_only_unimported_merge_requests, - default_enabled: :yaml - ) - end - - def each_merge_request_skipping_imported - project.merge_requests.find_each do |merge_request| - next if already_imported?(merge_request) - - Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :fetched) - - client - .pull_request_reviews(project.import_source, merge_request.iid) - .each do |review| - review.merge_request_id = merge_request.id - yield(review) - end - - mark_as_imported(merge_request) - end - end - # The worker can be interrupted, by rate limit for instance, # in different situations. To avoid requesting already imported data, # if the worker is interrupted: @@ -82,7 +45,7 @@ module Gitlab # - before importing all merge requests reviews # Merge requests that had all the reviews imported are cached with # `mark_merge_request_reviews_imported` - def each_merge_request_to_import + def each_object_to_import(&block) each_review_page do |page, merge_request| page.objects.each do |review| next if already_imported?(review) @@ -97,6 +60,10 @@ module Gitlab end end + private + + attr_reader :merge_requests_already_imported_cache_key + def each_review_page merge_requests_to_import.find_each do |merge_request| # The page counter needs to be scoped by merge request to avoid skipping |