From 83e468a4f817ffcb00324ef099a8c8db1fe7e240 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 15 Nov 2021 09:34:36 -0800 Subject: [PATCH] Fixes "indeterminate" state of progress indicator on screen reader --- bookwyrm/templates/import/import_status.html | 2 +- bookwyrm/views/imports/import_status.py | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/bookwyrm/templates/import/import_status.html b/bookwyrm/templates/import/import_status.html index ddeeeb31..61763ec2 100644 --- a/bookwyrm/templates/import/import_status.html +++ b/bookwyrm/templates/import/import_status.html @@ -51,7 +51,7 @@
- {{ percent }}% + {{ percent }} % {{ percent }}%
diff --git a/bookwyrm/views/imports/import_status.py b/bookwyrm/views/imports/import_status.py index 8e07a171..26ff8cde 100644 --- a/bookwyrm/views/imports/import_status.py +++ b/bookwyrm/views/imports/import_status.py @@ -32,20 +32,25 @@ class ImportStatus(View): paginated = Paginator(items, PAGE_LENGTH) page = paginated.get_page(request.GET.get("page")) + manual_review_count = items.filter( + fail_reason__isnull=False, book_guess__isnull=False, book__isnull=True + ).count() + fail_count = items.filter( + fail_reason__isnull=False, book_guess__isnull=True + ).count() + pending_item_count = job.pending_items.count() data = { "job": job, "items": page, - "manual_review_count": items.filter( - fail_reason__isnull=False, book_guess__isnull=False, book__isnull=True - ).count(), - "fail_count": items.filter( - fail_reason__isnull=False, book_guess__isnull=True - ).count(), + "manual_review_count": manual_review_count, + "fail_count": fail_count, "page_range": paginated.get_elided_page_range( page.number, on_each_side=2, on_ends=1 ), + "item_count": item_count, + "complete_count": item_count - pending_item_count, "percent": math.floor( # pylint: disable=c-extension-no-member - (item_count - job.pending_items.count()) / item_count * 100 + (item_count - pending_item_count) / item_count * 100 ), # hours since last import item update "inactive_time": (job.updated_date - timezone.now()).seconds / 60 / 60,