abstract_importer 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddf30730dc02843631c647c8f342623ebc46a87e
|
4
|
+
data.tar.gz: 571852378a10de0e78df4952ad9241c0af25092d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac466e7b1f05a6074ae42d8e9dc188b641f8210caf95277e54830a4dd05a0c73a794392a8ee77dca07c5c600fb4ff47b9d5acc54f41c5f3c677c396db788ead9
|
7
|
+
data.tar.gz: 3283e7ad8cb0b45d5364d917efdc28565755114f099113000b358411c1ec25e5c5fe3e3a75cf78b483b825bcf19cf6f1d4f655aca1ba8aaec5fa7420c434da45
|
data/abstract_importer.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_dependency "activerecord", ">= 5.0"
|
21
21
|
spec.add_dependency "activesupport", ">= 5.0"
|
22
|
-
spec.add_dependency "activerecord-insert_many", ">= 0.4.
|
22
|
+
spec.add_dependency "activerecord-insert_many", ">= 0.4.3"
|
23
23
|
spec.add_dependency "progressbar"
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
@@ -10,6 +10,7 @@ module AbstractImporter
|
|
10
10
|
@batch = []
|
11
11
|
@batch_size = options.fetch(:batch_size, 250)
|
12
12
|
@insert_options = options.slice(:on_conflict)
|
13
|
+
@insert_options.merge!(returning: [:legacy_id, :id]) if remap_ids?
|
13
14
|
end
|
14
15
|
|
15
16
|
|
@@ -43,8 +44,6 @@ module AbstractImporter
|
|
43
44
|
|
44
45
|
insert_batch(@batch)
|
45
46
|
|
46
|
-
id_map_record_batch(@batch) if remap_ids?
|
47
|
-
|
48
47
|
summary.created += @batch.length
|
49
48
|
reporter.batch_inserted(@batch.length)
|
50
49
|
|
@@ -53,7 +52,8 @@ module AbstractImporter
|
|
53
52
|
|
54
53
|
|
55
54
|
def insert_batch(batch)
|
56
|
-
collection.scope.insert_many(batch, @insert_options)
|
55
|
+
result = collection.scope.insert_many(batch, @insert_options)
|
56
|
+
add_batch_to_id_map(result) if remap_ids?
|
57
57
|
end
|
58
58
|
|
59
59
|
|
@@ -65,10 +65,11 @@ module AbstractImporter
|
|
65
65
|
end
|
66
66
|
|
67
67
|
|
68
|
-
def
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
def add_batch_to_id_map(result)
|
69
|
+
map = result.each_with_object({}) do |attrs, map|
|
70
|
+
map[attrs.fetch("legacy_id")] = attrs.fetch("id")
|
71
|
+
end
|
72
|
+
id_map.merge! collection.table_name, map
|
72
73
|
end
|
73
74
|
|
74
75
|
|
@@ -17,7 +17,7 @@ class InsertStrategyTest < ActiveSupport::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
should "import the records in batches" do
|
20
|
-
mock.proxy(Student).insert_many(satisfy { |arg| arg.length == 3 },
|
20
|
+
mock.proxy(Student).insert_many(satisfy { |arg| arg.length == 3 }, anything)
|
21
21
|
import!
|
22
22
|
assert_equal [456, 457, 458], account.students.pluck(:legacy_id)
|
23
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abstract_importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Lail
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.4.
|
47
|
+
version: 0.4.3
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.4.
|
54
|
+
version: 0.4.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: progressbar
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|