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 "Recent Imports" %}

- {% if not jobs %} -

{% trans "No recent imports" %}

- {% endif %} - +
+ + + + + + + + {% if not jobs %} + + + + {% endif %} + {% for job in jobs %} + + + + + + + {% endfor %} +
+ {% 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 %} +
+
{% include 'snippets/pagination.html' with page=jobs path=request.path %}
diff --git a/bookwyrm/views/imports/import_status.py b/bookwyrm/views/imports/import_status.py index ffad36774..2f6b13bba 100644 --- a/bookwyrm/views/imports/import_status.py +++ b/bookwyrm/views/imports/import_status.py @@ -1,6 +1,4 @@ """ import books from another app """ -import math - from django.contrib.auth.decorators import login_required from django.core.exceptions import PermissionDenied from django.core.paginator import Paginator @@ -38,7 +36,7 @@ class ImportStatus(View): fail_count = items.filter( fail_reason__isnull=False, book_guess__isnull=True ).count() - pending_item_count = job.pending_items.count() + pending_item_count = job.pending_item_count data = { "job": job, "items": page, @@ -50,9 +48,7 @@ class ImportStatus(View): "show_progress": True, "item_count": item_count, "complete_count": item_count - pending_item_count, - "percent": math.floor( # pylint: disable=c-extension-no-member - (item_count - pending_item_count) / item_count * 100 - ), + "percent": job.percent_complete, # hours since last import item update "inactive_time": (job.updated_date - timezone.now()).seconds / 60 / 60, "legacy": not job.mappings,