diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py index 060f11ede..b6a6ded41 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,12 @@ 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 + 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 30e05c5c1..3757d37ef 100644 --- a/bookwyrm/templates/import/import.html +++ b/bookwyrm/templates/import/import.html @@ -89,14 +89,53 @@
{% trans "No recent imports" %}
- {% endif %} -+ {% trans "Date Created" %} + | ++ {% trans "Last Updated" %} + | ++ {% trans "Items" %} + | ++ {% trans "Status" %} + | +
---|---|---|---|
+ {% trans "No recent imports" %} + | +|||
+ {{ job.created_date }} + | +{{ job.updated_date }} | +{{ job.item_count|intcomma }} | ++ {% if job.complete %} + + {% trans "Completed" %} + + {% else %} + + {% blocktrans trimmed with percent=job.percent_complete %} + Active, {{ percent }}% complete + {% endblocktrans %} + + {% endif %} + | +