blob: eaff99aed433e901f72ee88233d8a443bd0bd588 (
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
55
|
# frozen_string_literal: true
module Gitlab
module GithubImport
module Importer
module Attachments
class BaseImporter
include ParallelScheduling
BATCH_SIZE = 100
# The method that will be called for traversing through all the objects to
# import, yielding them to the supplied block.
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
def representation_class
Representation::NoteText
end
def importer_class
NoteAttachmentsImporter
end
private
def collection
raise Gitlab::GithubImport::Exceptions::NotImplementedError, '#collection'
end
def ordering_column
:id
end
def object_representation(object)
representation_class.from_db_record(object)
end
end
end
end
end
end
|