[Groonga-commit] droonga/drndump at ca8b397 [master] Add messages to help reporting progress

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Apr 17 16:56:09 JST 2015


YUKI Hiroshi	2015-04-17 16:56:09 +0900 (Fri, 17 Apr 2015)

  New Revision: ca8b3971ac6beb0d8812443307366231140ea771
  https://github.com/droonga/drndump/commit/ca8b3971ac6beb0d8812443307366231140ea771

  Message:
    Add messages to help reporting progress

  Modified files:
    lib/drndump/dump_client.rb

  Modified: lib/drndump/dump_client.rb (+23 -0)
===================================================================
--- lib/drndump/dump_client.rb    2015-04-17 16:55:36 +0900 (0b5fd6f)
+++ lib/drndump/dump_client.rb    2015-04-17 16:56:09 +0900 (391757d)
@@ -137,6 +137,29 @@ module Drndump
       @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
-------------- next part --------------
HTML����������������������������...
Descargar 



More information about the Groonga-commit mailing list
Back to archive index