tapsoob 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tapsoob/cli/data_stream.rb +2 -0
- data/lib/tapsoob/cli/root.rb +2 -0
- data/lib/tapsoob/data_stream.rb +1 -1
- data/lib/tapsoob/operation.rb +8 -2
- data/lib/tapsoob/progress_bar.rb +6 -6
- data/lib/tapsoob/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 661f0fd554e2cd6781c9a174c4051331024879fb1abecb9f48f19b9e365c1e46
|
4
|
+
data.tar.gz: 10535d8376543d13e16a35b8d7e098cdb4c4757b518e75068d6a83884196cd98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 171152e81bcb75da25c9865b8b8211256e7fce176bca88f576b4eb9cf159d67a66badacc51344b3c3a4efa137f16dd57384f606780f0b35984ecfb1d6bfbe96c
|
7
|
+
data.tar.gz: a9a59c2a045419d2b580b9d3932055f012f9b192daf6feef8e35602546b0b8dcbd77fc87e56ffa728c1818c6de5004b8027cc0051c9e44d313acc1c5673bc862
|
@@ -29,6 +29,7 @@ module Tapsoob
|
|
29
29
|
option :"exclude-tables", desc: "Shortcut to exclude a list of tables", type: :array, aliases: "-e"
|
30
30
|
option :progress, desc: "Show progress", default: true, type: :boolean, aliases: "-p"
|
31
31
|
option :purge, desc: "Purge data in tables prior to performing the import", default: false, type: :boolean, aliases: "-p"
|
32
|
+
option :"skip-duplicates", desc: "Remove duplicates when loading data", default: false, type: :boolean
|
32
33
|
option :"discard-identity", desc: "Remove identity when pushing data (may result in creating duplicates)", default: false, type: :boolean
|
33
34
|
option :debug, desc: "Enable debug messages", default: false, type: :boolean, aliases: "-d"
|
34
35
|
def push(database_url, dump_path = nil)
|
@@ -69,6 +70,7 @@ module Tapsoob
|
|
69
70
|
|
70
71
|
# Push only options
|
71
72
|
opts[:purge] = options[:purge] if options.key?(:purge)
|
73
|
+
opts[:"skip-duplicates"] = options[:"skip-duplicates"] if options.key?(:"skip-duplicates")
|
72
74
|
opts[:"discard-identity"] = options[:"discard-identity"] if options.key?(:"discard-identity")
|
73
75
|
|
74
76
|
# Default chunksize
|
data/lib/tapsoob/cli/root.rb
CHANGED
@@ -39,6 +39,7 @@ module Tapsoob
|
|
39
39
|
option :tables, desc: "Shortcut to filter on a list of tables", type: :array, aliases: "-t"
|
40
40
|
option :"exclude-tables", desc: "Shortcut to exclude a list of tables", type: :array, aliases: "-e"
|
41
41
|
option :purge, desc: "Purge data in tables prior to performing the import", default: false, type: :boolean, aliases: "-p"
|
42
|
+
option :"skip-duplicates", desc: "Remove duplicates when loading data", default: false, type: :boolean
|
42
43
|
option :"discard-identity", desc: "Remove identity when pushing data (may result in creating duplicates)", default: false, type: :boolean
|
43
44
|
option :debug, desc: "Enable debug messages", default: false, type: :boolean, aliases: "-d"
|
44
45
|
def push(dump_path, database_url)
|
@@ -74,6 +75,7 @@ module Tapsoob
|
|
74
75
|
|
75
76
|
# Push only options
|
76
77
|
opts[:purge] = options[:purge] if options.key?(:purge)
|
78
|
+
opts[:"skip-duplicates"] = options[:"skip-duplicates"] if options.key?(:"skip-duplicates")
|
77
79
|
opts[:"discard-identity"] = options[:"discard-identity"] if options.key?(:"discard-identity")
|
78
80
|
|
79
81
|
# Resume
|
data/lib/tapsoob/data_stream.rb
CHANGED
@@ -91,7 +91,7 @@ module Tapsoob
|
|
91
91
|
rows = {
|
92
92
|
:table_name => ds["table_name"],
|
93
93
|
:header => ds["header"],
|
94
|
-
:data => (ds["data"][state[:offset], (state[:offset] + state[:chunksize])] || [ ]),
|
94
|
+
:data => ((@options[:"skip-duplicates"] ? ds["data"].uniq : ds["data"])[state[:offset], (state[:offset] + state[:chunksize])] || [ ]),
|
95
95
|
:types => ds["types"]
|
96
96
|
}
|
97
97
|
update_chunksize_stats
|
data/lib/tapsoob/operation.rb
CHANGED
@@ -393,10 +393,16 @@ module Tapsoob
|
|
393
393
|
|
394
394
|
tables.each do |table_name, count|
|
395
395
|
next unless File.exists?(File.join(dump_path, "data", "#{table_name}.json"))
|
396
|
-
db[
|
396
|
+
db[table_name.to_sym].truncate if @opts[:purge]
|
397
397
|
stream = Tapsoob::DataStream.factory(db, {
|
398
398
|
:table_name => table_name,
|
399
|
-
:chunksize => default_chunksize
|
399
|
+
:chunksize => default_chunksize
|
400
|
+
}, {
|
401
|
+
:"skip-duplicates" => opts[:"skip-duplicates"] || false,
|
402
|
+
:"discard-identity" => opts[:"discard-identity"] || false,
|
403
|
+
:purge => opts[:purge] || false,
|
404
|
+
:debug => opts[:debug]
|
405
|
+
})
|
400
406
|
progress = ProgressBar.new(table_name.to_s, count)
|
401
407
|
push_data_from_file(stream, progress)
|
402
408
|
end
|
data/lib/tapsoob/progress_bar.rb
CHANGED
@@ -22,7 +22,7 @@ class ProgressBar
|
|
22
22
|
@current = 0
|
23
23
|
@previous = 0
|
24
24
|
@finished_p = false
|
25
|
-
@start_time = Time.now
|
25
|
+
@start_time = ::Time.now
|
26
26
|
@previous_time = @start_time
|
27
27
|
@title_width = 14
|
28
28
|
@format = "%-#{@title_width}s %3d%% %s %s"
|
@@ -76,7 +76,7 @@ class ProgressBar
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def transfer_rate
|
79
|
-
bytes_per_second = @current.to_f / (Time.now - @start_time)
|
79
|
+
bytes_per_second = @current.to_f / (::Time.now - @start_time)
|
80
80
|
sprintf("%s/s", convert_bytes(bytes_per_second))
|
81
81
|
end
|
82
82
|
|
@@ -97,14 +97,14 @@ class ProgressBar
|
|
97
97
|
if @current == 0
|
98
98
|
"ETA: --:--:--"
|
99
99
|
else
|
100
|
-
elapsed = Time.now - @start_time
|
100
|
+
elapsed = ::Time.now - @start_time
|
101
101
|
eta = elapsed * @total / @current - elapsed;
|
102
102
|
sprintf("ETA: %s", format_time(eta))
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
def elapsed
|
107
|
-
elapsed = Time.now - @start_time
|
107
|
+
elapsed = ::Time.now - @start_time
|
108
108
|
sprintf("Time: %s", format_time(elapsed))
|
109
109
|
end
|
110
110
|
|
@@ -155,7 +155,7 @@ class ProgressBar
|
|
155
155
|
@terminal_width += width - line.length + 1
|
156
156
|
show
|
157
157
|
end
|
158
|
-
@previous_time = Time.now
|
158
|
+
@previous_time = ::Time.now
|
159
159
|
end
|
160
160
|
|
161
161
|
def show_if_needed
|
@@ -169,7 +169,7 @@ class ProgressBar
|
|
169
169
|
|
170
170
|
# Use "!=" instead of ">" to support negative changes
|
171
171
|
if cur_percentage != prev_percentage ||
|
172
|
-
Time.now - @previous_time >= 1 || @finished_p
|
172
|
+
::Time.now - @previous_time >= 1 || @finished_p
|
173
173
|
show
|
174
174
|
end
|
175
175
|
end
|
data/lib/tapsoob/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapsoob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Félix Bellanger
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-06-
|
12
|
+
date: 2021-06-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ripl
|