diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py index 060f11ede..20a5662f9 100644 --- a/bookwyrm/models/import_job.py +++ b/bookwyrm/models/import_job.py @@ -1,4 +1,5 @@ """ track progress of goodreads imports """ +import math import re import dateutil.parser @@ -53,6 +54,14 @@ class ImportJob(models.Model): """How many books do you want to import???""" return self.items.count() + @property + def percent_complete(self): + """How far along?""" + item_count = self.item_count + if not item_count: + return 0 + return math.floor((item_count - self.pending_item_count) / item_count * 100) + @property def pending_item_count(self): """And how many pending items??""" diff --git a/bookwyrm/templates/import/import.html b/bookwyrm/templates/import/import.html index 9657773d6..3757d37ef 100644 --- a/bookwyrm/templates/import/import.html +++ b/bookwyrm/templates/import/import.html @@ -7,12 +7,28 @@ {% block content %}
+ {% if recent_avg_hours %} + {% blocktrans trimmed with hours=recent_avg_hours|floatformat:0|intcomma %} + On average, recent imports have taken {{ hours }} hours. + {% endblocktrans %} + {% else %} + {% blocktrans trimmed with minutes=recent_avg_minutes|floatformat:0|intcomma %} + On average, recent imports have taken {{ minutes }} minutes. + {% endblocktrans %} + {% endif %} +
+