row_boat 0.1.0.alpha.1 → 0.1.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/row_boat/base.rb +16 -6
- data/lib/row_boat/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a52e0cc320cec32723d8004c8664b20db8b2f08c
|
4
|
+
data.tar.gz: 44976205d05e7290b9cc520e4af0a2b8bb864928
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0cd75d81d723f853a42d8dd4eeee8a9a03bc783b46778457d6b01db3006b3e276531237f57dec9fb26d36447f14d95b9b138b710bab8e7485caf6f761b03c6c
|
7
|
+
data.tar.gz: 2dce2747abf8ba12b093a393c6db92a06c7e35a61892184c8c85c4dda557ddec75b9a59446bb38d987e9ca67598111a6972da54c7e11accc124addfa6db962d6
|
data/lib/row_boat/base.rb
CHANGED
@@ -27,7 +27,11 @@ module RowBoat
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
import_results.each_with_object(invalid_records: [], total_inserted: 0, inserted_ids: []) do |import_result, total_results|
|
31
|
+
total_results[:invalid_records] += import_result.failed_instances
|
32
|
+
total_results[:total_inserted] += import_result.num_inserts
|
33
|
+
total_results[:inserted_ids] += import_result.ids
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
def import_into
|
@@ -38,10 +42,21 @@ module RowBoat
|
|
38
42
|
raise NotImplementedError, not_implemented_error_message(__method__)
|
39
43
|
end
|
40
44
|
|
45
|
+
def preprocess_row(row)
|
46
|
+
row
|
47
|
+
end
|
48
|
+
|
49
|
+
def import_rows(rows)
|
50
|
+
import_options = ::RowBoat::Helpers.extract_import_options(options)
|
51
|
+
preprocessed_rows = rows.map { |row| preprocess_row(row) }
|
52
|
+
import_into.import(preprocessed_rows, import_options)
|
53
|
+
end
|
54
|
+
|
41
55
|
def options
|
42
56
|
{
|
43
57
|
chunk_size: 500,
|
44
58
|
key_mapping: column_mapping,
|
59
|
+
recursive: true,
|
45
60
|
remove_unmapped_keys: true,
|
46
61
|
validate: true,
|
47
62
|
wrap_in_transaction: true
|
@@ -59,11 +74,6 @@ module RowBoat
|
|
59
74
|
::SmarterCSV.process(csv_source, csv_options, &block)
|
60
75
|
end
|
61
76
|
|
62
|
-
def import_rows(rows)
|
63
|
-
import_options = ::RowBoat::Helpers.extract_import_options(options)
|
64
|
-
import_into.import(rows, import_options)
|
65
|
-
end
|
66
|
-
|
67
77
|
def transaction_if_needed(&block)
|
68
78
|
options[:wrap_in_transaction] ? import_into.transaction(&block) : yield
|
69
79
|
end
|
data/lib/row_boat/version.rb
CHANGED