mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 10:01:04 +00:00
Show recent imports in a table
This commit is contained in:
parent
4806a6273e
commit
3c2f2c10bf
3 changed files with 56 additions and 14 deletions
|
@ -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??"""
|
||||
|
|
|
@ -89,14 +89,53 @@
|
|||
|
||||
<div class="content block">
|
||||
<h2 class="title">{% trans "Recent Imports" %}</h2>
|
||||
{% if not jobs %}
|
||||
<p><em>{% trans "No recent imports" %}</em></p>
|
||||
{% endif %}
|
||||
<ul>
|
||||
{% for job in jobs %}
|
||||
<li><a href="{% url 'import-status' job.id %}">{{ job.created_date | naturaltime }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="table-container">
|
||||
<table class="table is-striped is-fullwidth">
|
||||
<tr>
|
||||
<th>
|
||||
{% trans "Date Created" %}
|
||||
</th>
|
||||
<th>
|
||||
{% trans "Last Updated" %}
|
||||
</th>
|
||||
<th>
|
||||
{% trans "Items" %}
|
||||
</th>
|
||||
<th>
|
||||
{% trans "Status" %}
|
||||
</th>
|
||||
</tr>
|
||||
{% if not jobs %}
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<em>{% trans "No recent imports" %}</em>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% for job in jobs %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'import-status' job.id %}">{{ job.created_date }}</a>
|
||||
</td>
|
||||
<td>{{ job.updated_date }}</td>
|
||||
<td>{{ job.item_count|intcomma }}</td>
|
||||
<td>
|
||||
{% if job.complete %}
|
||||
<span class="tag is-success">
|
||||
{% trans "Completed" %}
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="tag is-warning">
|
||||
{% blocktrans trimmed with percent=job.percent_complete %}
|
||||
Active, {{ percent }}% complete
|
||||
{% endblocktrans %}
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% include 'snippets/pagination.html' with page=jobs path=request.path %}
|
||||
</div>
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue