Welcome to mirror list, hosted at ThFree Co, Russian Federation.

single_endpoint_merge_request_notes_importer.rb « importer « github_import « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d837639c14db772ed9098fe928e1dda32d7d0504 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# frozen_string_literal: true

# This importer is used when `github_importer_single_endpoint_notes_import`
# feature flag is on and replaces `NotesImporter` MR notes import.
#
# It fetches 1 PR's comments at a time using `issue_comments` endpoint, which is
# slower than `NotesImporter` but it makes sure all notes are imported,
# as it can sometimes not be the case for `NotesImporter`, because
# `issues_comments` endpoint it uses can be limited by GitHub API
# to not return all available pages.
module Gitlab
  module GithubImport
    module Importer
      class SingleEndpointMergeRequestNotesImporter
        include ParallelScheduling
        include SingleEndpointNotesImporting

        def importer_class
          NoteImporter
        end

        def representation_class
          Representation::Note
        end

        def sidekiq_worker_class
          ImportNoteWorker
        end

        def object_type
          :note
        end

        def collection_method
          :issue_comments
        end

        private

        def noteables
          project.merge_requests.where.not(iid: already_imported_noteables) # rubocop: disable CodeReuse/ActiveRecord
        end

        def page_counter_id(merge_request)
          "merge_request/#{merge_request.id}/#{collection_method}"
        end

        def notes_imported_cache_key
          "github-importer/merge_request/notes/already-imported/#{project.id}"
        end
      end
    end
  end
end