Merge pull request #2517 from bookwyrm-social/import-status

Don't mark imports as active until their job task runs
This commit is contained in:
Mouse Reeve 2022-12-16 14:50:23 -08:00 committed by GitHub
commit e9ad1b4bf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -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"""
@ -332,6 +331,8 @@ class ImportItem(models.Model):
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

View file

@ -41,7 +41,7 @@
</dl>
</div>
{% if not job.complete and show_progress %}
{% if job.status == "active" and show_progress %}
<div class="box is-processing">
<div class="block">
<span class="icon icon-spinner is-pulled-left" aria-hidden="true"></span>