tapsoob 0.5.26-java → 0.5.28-java
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/operation.rb +14 -7
- data/lib/tapsoob/version.rb +1 -1
- data/lib/tasks/tapsoob.rake +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7554a38a7588261f53f4d653a513c7befc0fe900bd4ca2e12707623f3e574d82
|
4
|
+
data.tar.gz: df55e85a95cba4f95c30a9eeabd3d7523949ff492422159d997a6d848bb1c39f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 804658b12d9d1f43fbc80670645854ccaa54e3cc915e754e3433efa61738a646d73afa2ddf28fee2f317ffc3e8d269778a9533e31aa9bc7cf2b7cfb8f1d04ffc
|
7
|
+
data.tar.gz: ac1ff9b60b5b52fcadd568b772337a8257b814fa23cc2d6b035fabf5d2c99de320ea1054e45fae4c955ec1a2de2de1ff3a34f9eba947b4fbfaeb721b9d01f3f8
|
data/lib/tapsoob/operation.rb
CHANGED
@@ -198,11 +198,12 @@ module Tapsoob
|
|
198
198
|
log.info "#{tables.size} tables, #{format_number(record_count)} records"
|
199
199
|
|
200
200
|
tables.each do |table_name, count|
|
201
|
-
progress = (opts[:progress] ? ProgressBar.new(table_name.to_s, count) : nil)
|
202
201
|
stream = Tapsoob::DataStream.factory(db, {
|
203
202
|
:chunksize => default_chunksize,
|
204
203
|
:table_name => table_name
|
205
204
|
}, { :debug => opts[:debug] })
|
205
|
+
estimated_chunks = [(count.to_f / default_chunksize).ceil, 1].max
|
206
|
+
progress = (opts[:progress] ? ProgressBar.new(table_name.to_s, estimated_chunks) : nil)
|
206
207
|
pull_data_from_table(stream, progress)
|
207
208
|
end
|
208
209
|
end
|
@@ -214,8 +215,10 @@ module Tapsoob
|
|
214
215
|
record_count = tables[table_name.to_s]
|
215
216
|
log.info "Resuming #{table_name}, #{format_number(record_count)} records"
|
216
217
|
|
217
|
-
progress = (opts[:progress] ? ProgressBar.new(table_name.to_s, record_count) : nil)
|
218
218
|
stream = Tapsoob::DataStream.factory(db, stream_state)
|
219
|
+
chunksize = stream_state[:chunksize] || default_chunksize
|
220
|
+
estimated_chunks = [(record_count.to_f / chunksize).ceil, 1].max
|
221
|
+
progress = (opts[:progress] ? ProgressBar.new(table_name.to_s, estimated_chunks) : nil)
|
219
222
|
pull_data_from_table(stream, progress)
|
220
223
|
end
|
221
224
|
|
@@ -249,8 +252,8 @@ module Tapsoob
|
|
249
252
|
stream.fetch_data_from_database(data) do |rows|
|
250
253
|
next if rows == {}
|
251
254
|
|
252
|
-
# Update progress bar
|
253
|
-
progress.inc(
|
255
|
+
# Update progress bar by 1 chunk
|
256
|
+
progress.inc(1) if progress
|
254
257
|
|
255
258
|
if dump_path.nil?
|
256
259
|
puts JSON.generate(rows)
|
@@ -420,8 +423,10 @@ module Tapsoob
|
|
420
423
|
table_name = stream_state[:table_name]
|
421
424
|
record_count = tables[table_name.to_s]
|
422
425
|
log.info "Resuming #{table_name}, #{format_number(record_count)} records"
|
423
|
-
progress = ProgressBar.new(table_name.to_s, record_count)
|
424
426
|
stream = Tapsoob::DataStream.factory(db, stream_state)
|
427
|
+
chunksize = stream_state[:chunksize] || default_chunksize
|
428
|
+
estimated_chunks = [(record_count.to_f / chunksize).ceil, 1].max
|
429
|
+
progress = (opts[:progress] ? ProgressBar.new(table_name.to_s, estimated_chunks) : nil)
|
425
430
|
push_data_from_file(stream, progress)
|
426
431
|
end
|
427
432
|
|
@@ -442,7 +447,8 @@ module Tapsoob
|
|
442
447
|
:purge => opts[:purge] || false,
|
443
448
|
:debug => opts[:debug]
|
444
449
|
})
|
445
|
-
|
450
|
+
estimated_chunks = [(count.to_f / default_chunksize).ceil, 1].max
|
451
|
+
progress = (opts[:progress] ? ProgressBar.new(table_name.to_s, estimated_chunks) : nil)
|
446
452
|
push_data_from_file(stream, progress)
|
447
453
|
end
|
448
454
|
end
|
@@ -493,7 +499,8 @@ module Tapsoob
|
|
493
499
|
end
|
494
500
|
stream.state[:chunksize] = chunksize
|
495
501
|
|
496
|
-
progress
|
502
|
+
# Update progress bar by 1 chunk
|
503
|
+
progress.inc(1) if progress
|
497
504
|
|
498
505
|
break if stream.complete?
|
499
506
|
end
|
data/lib/tapsoob/version.rb
CHANGED
data/lib/tasks/tapsoob.rake
CHANGED
@@ -2,7 +2,7 @@ namespace :tapsoob do
|
|
2
2
|
desc "Pulls a database to your filesystem"
|
3
3
|
task :pull => :environment do
|
4
4
|
# Default options
|
5
|
-
opts={:default_chunksize => 1000, :debug => false, :resume_filename => nil, :disable_compression => false, :schema => true, :data => true, :indexes_first => false}
|
5
|
+
opts={:default_chunksize => 1000, :debug => false, :resume_filename => nil, :disable_compression => false, :schema => true, :data => true, :indexes_first => false, :progress => true}
|
6
6
|
|
7
7
|
# Get the dump_path
|
8
8
|
dump_path = File.expand_path(Rails.root.join("db", Time.now.strftime("%Y%m%d%I%M%S%p"))).to_s
|
@@ -23,7 +23,7 @@ namespace :tapsoob do
|
|
23
23
|
desc "Push a compatible dump on your filesystem to a database"
|
24
24
|
task :push, [:timestamp] => :environment do |t, args|
|
25
25
|
# Default options
|
26
|
-
opts={:default_chunksize => 1000, :debug => false, :resume_filename => nil, :disable_compression => false, :schema => true, :data => true, :indexes_first => false}
|
26
|
+
opts={:default_chunksize => 1000, :debug => false, :resume_filename => nil, :disable_compression => false, :schema => true, :data => true, :indexes_first => false, :progress => true}
|
27
27
|
|
28
28
|
# Get the dumps
|
29
29
|
dumps = Dir[Rails.root.join("db", "*/")].select { |e| e =~ /([0-9]{14})([A-Z]{2})/ }.sort
|