Navigation Menu

Skip to content

Commit

Permalink
Add messages to help reporting progress
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 17, 2015
1 parent 47ac7ab commit ca8b397
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/drndump/dump_client.rb
Expand Up @@ -137,6 +137,29 @@ def run(options={}, &block)
@error_message
end

def n_remaining_messages
[@n_forecasted_messages - @n_received_messages, 0].max
end

def remaining_seconds
n_remaining_messages.to_f / @n_messages_per_second
end

ONE_MINUTE_IN_SECONDS = 60
ONE_HOUR_IN_SECONDS = ONE_MINUTE_IN_SECONDS * 60

def formatted_remaining_time
seconds = remaining_seconds
hours = (seconds / ONE_HOUR_IN_SECONDS).floor
seconds -= hours * ONE_HOUR_IN_SECONDS
minutes = (seconds / ONE_MINUTE_IN_SECONDS).floor
seconds -= minutes * ONE_MINUTE_IN_SECONDS
sprintf("%02i:%02i:%02i",
remaining_hours,
remaining_minutes,
remaining_seconds)
end

def progress_percentage
return 0 if @n_forecasted_messages.zero?
progress = @n_received_messages.to_f / @n_forecasted_messages
Expand Down

0 comments on commit ca8b397

Please sign in to comment.