mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-27 12:01:14 +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 """
|
""" track progress of goodreads imports """
|
||||||
|
import math
|
||||||
import re
|
import re
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
|
|
||||||
|
@ -53,6 +54,12 @@ class ImportJob(models.Model):
|
||||||
"""How many books do you want to import???"""
|
"""How many books do you want to import???"""
|
||||||
return self.items.count()
|
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
|
@property
|
||||||
def pending_item_count(self):
|
def pending_item_count(self):
|
||||||
"""And how many pending items??"""
|
"""And how many pending items??"""
|
||||||
|
|
|
@ -89,14 +89,53 @@
|
||||||
|
|
||||||
<div class="content block">
|
<div class="content block">
|
||||||
<h2 class="title">{% trans "Recent Imports" %}</h2>
|
<h2 class="title">{% trans "Recent Imports" %}</h2>
|
||||||
{% if not jobs %}
|
<div class="table-container">
|
||||||
<p><em>{% trans "No recent imports" %}</em></p>
|
<table class="table is-striped is-fullwidth">
|
||||||
{% endif %}
|
<tr>
|
||||||
<ul>
|
<th>
|
||||||
{% for job in jobs %}
|
{% trans "Date Created" %}
|
||||||
<li><a href="{% url 'import-status' job.id %}">{{ job.created_date | naturaltime }}</a></li>
|
</th>
|
||||||
{% endfor %}
|
<th>
|
||||||
</ul>
|
{% 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 %}
|
{% include 'snippets/pagination.html' with page=jobs path=request.path %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
""" import books from another app """
|
""" import books from another app """
|
||||||
import math
|
|
||||||
|
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
|
@ -38,7 +36,7 @@ class ImportStatus(View):
|
||||||
fail_count = items.filter(
|
fail_count = items.filter(
|
||||||
fail_reason__isnull=False, book_guess__isnull=True
|
fail_reason__isnull=False, book_guess__isnull=True
|
||||||
).count()
|
).count()
|
||||||
pending_item_count = job.pending_items.count()
|
pending_item_count = job.pending_item_count
|
||||||
data = {
|
data = {
|
||||||
"job": job,
|
"job": job,
|
||||||
"items": page,
|
"items": page,
|
||||||
|
@ -50,9 +48,7 @@ class ImportStatus(View):
|
||||||
"show_progress": True,
|
"show_progress": True,
|
||||||
"item_count": item_count,
|
"item_count": item_count,
|
||||||
"complete_count": item_count - pending_item_count,
|
"complete_count": item_count - pending_item_count,
|
||||||
"percent": math.floor( # pylint: disable=c-extension-no-member
|
"percent": job.percent_complete,
|
||||||
(item_count - pending_item_count) / item_count * 100
|
|
||||||
),
|
|
||||||
# hours since last import item update
|
# hours since last import item update
|
||||||
"inactive_time": (job.updated_date - timezone.now()).seconds / 60 / 60,
|
"inactive_time": (job.updated_date - timezone.now()).seconds / 60 / 60,
|
||||||
"legacy": not job.mappings,
|
"legacy": not job.mappings,
|
||||||
|
|
Loading…
Reference in a new issue