Permalink
Browse files

Added the data transferring progress display

  • Loading branch information...
1 parent 6abbcd1 commit 5a8c61910134ce362eca3ed9bcc3968488da699f @MadRabbit MadRabbit committed Oct 2, 2010
Showing with 16 additions and 2 deletions.
  1. +16 −2 lib/heroku/command/mongo.rb
@@ -28,13 +28,27 @@ def transfer(from, to)
origin.collections.each do |col|
next if col.name =~ /^system\./
- display "Syncing #{col.name} (#{col.size})...", false
dest.drop_collection(col.name)
dest_col = dest.create_collection(col.name)
+
+ count = col.size
+ index = 0
+ step = count / 100000 # 1/1000 of a percent
+ step = 1 if step == 0
+
col.find().each do |record|
dest_col.insert record
+
+ if (index += 1) % step == 0
+ display(
+ "\r#{"Syncing #{col.name}: %d of %d (%.2f%%)... " %
+ [index, count, (index.to_f/count * 100)]}",
+ false
+ )
+ end
end
- display " done"
+
+ display "\n done"
end
display "Syncing indexes...", false

0 comments on commit 5a8c619

Please sign in to comment.