Skip to content

Commit

Permalink
Added the data transferring progress display
Browse files Browse the repository at this point in the history
  • Loading branch information
kaievns committed Oct 2, 2010
1 parent 6abbcd1 commit 5a8c619
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/heroku/command/mongo.rb
Expand Up @@ -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
Expand Down

0 comments on commit 5a8c619

Please sign in to comment.