diff --git a/bookwyrm/activitystreams.py b/bookwyrm/activitystreams.py index 1765f7e34..80774e28d 100644 --- a/bookwyrm/activitystreams.py +++ b/bookwyrm/activitystreams.py @@ -318,6 +318,10 @@ def add_status_on_create_command(sender, instance, created): if instance.published_date < timezone.now() - timedelta( days=1 ) or instance.created_date < instance.published_date - timedelta(days=1): + # a backdated status from a local user is an import, don't add it + if instance.user.local: + return + # an out of date remote status is a low priority but should be added priority = LOW add_status_task.apply_async( diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py index d8cfad314..bdd88c687 100644 --- a/bookwyrm/models/import_job.py +++ b/bookwyrm/models/import_job.py @@ -19,7 +19,7 @@ from bookwyrm.models import ( Review, ReviewRating, ) -from bookwyrm.tasks import app, LOW +from bookwyrm.tasks import app, LOW, IMPORTS from .fields import PrivacyLevels @@ -74,8 +74,7 @@ class ImportJob(models.Model): task = start_import_task.delay(self.id) self.task_id = task.id - self.status = "active" - self.save(update_fields=["status", "task_id"]) + self.save(update_fields=["task_id"]) def complete_job(self): """Report that the job has completed""" @@ -328,10 +327,12 @@ class ImportItem(models.Model): ) -@app.task(queue=LOW) +@app.task(queue=IMPORTS) def start_import_task(job_id): """trigger the child tasks for each row""" job = ImportJob.objects.get(id=job_id) + job.status = "active" + job.save(update_fields=["status"]) # don't start the job if it was stopped from the UI if job.complete: return @@ -345,7 +346,7 @@ def start_import_task(job_id): job.save() -@app.task(queue=LOW) +@app.task(queue=IMPORTS) def import_item_task(item_id): """resolve a row into a book""" item = ImportItem.objects.get(id=item_id) diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index c885902f9..7df9da88d 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -373,6 +373,7 @@ class User(OrderedCollectionPageMixin, AbstractUser): """We don't actually delete the database entry""" # pylint: disable=attribute-defined-outside-init self.is_active = False + self.avatar = "" # skip the logic in this class's save() super().save(*args, **kwargs) diff --git a/bookwyrm/tasks.py b/bookwyrm/tasks.py index 09e1d267e..ec018e179 100644 --- a/bookwyrm/tasks.py +++ b/bookwyrm/tasks.py @@ -14,3 +14,5 @@ app = Celery( LOW = "low_priority" MEDIUM = "medium_priority" HIGH = "high_priority" +# import items get their own queue because they're such a pain in the ass +IMPORTS = "imports" diff --git a/bookwyrm/templates/annual_summary/layout.html b/bookwyrm/templates/annual_summary/layout.html index 597604504..8d399c212 100644 --- a/bookwyrm/templates/annual_summary/layout.html +++ b/bookwyrm/templates/annual_summary/layout.html @@ -123,16 +123,18 @@
{% trans "That’s great!" %}
-- {% blocktrans with pages=pages_average|intcomma %}That makes an average of {{ pages }} pages per book.{% endblocktrans %} -
+ {% if pages > 0 %} ++ {% blocktrans with pages=pages_average|intcomma %}That makes an average of {{ pages }} pages per book.{% endblocktrans %} +
+ {% endif %} {% if no_page_number %}{% blocktrans trimmed count counter=no_page_number %} - ({{ no_page_number }} book doesn’t have pages) + (No page data was available for {{ no_page_number }} book) {% plural %} - ({{ no_page_number }} books don’t have pages) + (No page data was available for {{ no_page_number }} books) {% endblocktrans %}
{% endif %} diff --git a/bookwyrm/templates/import/import_status.html b/bookwyrm/templates/import/import_status.html index 757ed49a9..02bd1fdf0 100644 --- a/bookwyrm/templates/import/import_status.html +++ b/bookwyrm/templates/import/import_status.html @@ -41,7 +41,7 @@ - {% if not job.complete and show_progress %} + {% if job.status == "active" and show_progress %}{% blocktrans trimmed with username=user.localname %} - Are you sure you want to delete {{ username}}'s account? This action cannot be undone. To proceed, please enter your password to confirm deletion. + Are you sure you want to delete {{username}}'s account? This action cannot be undone. To proceed, please enter your password to confirm deletion. {% endblocktrans %}