Browse Source

change algo for computing estimated time left till task completes

Rafał Pitoń 8 years ago
parent
commit
7ac11e422e
1 changed files with 4 additions and 2 deletions
  1. 4 2
      misago/core/management/progressbar.py

+ 4 - 2
misago/core/management/progressbar.py

@@ -10,8 +10,10 @@ def show_progress(command, step, total, since=None):
     rendered_line = line % (str(progress).rjust(3), '=' * filled, ' ' * blank)
 
     if since:
-        if step > 0:
-            estimated_time = ((time.time() - since) // step) * (total - step)
+        progress_float = float(step) * 100.0 / float(total)
+        if progress_float > 0:
+            step_time = (time.time() - since) / progress_float
+            estimated_time = (100 - progress) * step_time
             clock = time.strftime('%H:%M:%S', time.gmtime(estimated_time))
             rendered_line = '%s %s est.' % (rendered_line, clock)
         else: