Notify when import completes

This commit is contained in:
Mouse Reeve
2021-11-14 09:56:23 -08:00
parent 47b98ad0d9
commit f92863ad3e
6 changed files with 77 additions and 43 deletions

View File

@ -24,7 +24,6 @@ class ImportStatus(View):
raise PermissionDenied()
items = job.items.order_by("index")
pending_items = items.filter(fail_reason__isnull=True, book__isnull=True)
item_count = items.count() or 1
paginated = Paginator(items, PAGE_LENGTH)
@ -41,9 +40,9 @@ class ImportStatus(View):
"page_range": paginated.get_elided_page_range(
page.number, on_each_side=2, on_ends=1
),
"complete": not pending_items.exists(),
"complete": not job.pending_items.exists(),
"percent": math.floor( # pylint: disable=c-extension-no-member
(item_count - pending_items.count()) / item_count * 100
(item_count - job.pending_items.count()) / item_count * 100
),
}