mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-22 17:41:08 +00:00
Set import job status when job starts and finishes
This commit is contained in:
parent
59fe9e4d3b
commit
97513a43d6
3 changed files with 18 additions and 5 deletions
|
@ -135,6 +135,8 @@ def start_import_task(job_id):
|
|||
task = import_item_task.delay(item)
|
||||
item.task_id = task.id
|
||||
item.save()
|
||||
job.status = "active"
|
||||
job.save()
|
||||
|
||||
|
||||
@app.task(queue="low_priority")
|
||||
|
|
|
@ -6,13 +6,23 @@ from django.db import migrations, models
|
|||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bookwyrm', '0160_auto_20221105_2030'),
|
||||
("bookwyrm", "0160_auto_20221105_2030"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='importjob',
|
||||
name='status',
|
||||
field=models.CharField(choices=[('pending', 'Pending'), ('active', 'Active'), ('complete', 'Complete'), ('stopped', 'Stopped')], default='pending', max_length=50, null=True),
|
||||
model_name="importjob",
|
||||
name="status",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
("pending", "Pending"),
|
||||
("active", "Active"),
|
||||
("complete", "Complete"),
|
||||
("stopped", "Stopped"),
|
||||
],
|
||||
default="pending",
|
||||
max_length=50,
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -116,8 +116,9 @@ class ImportItem(models.Model):
|
|||
job.updated_date = timezone.now()
|
||||
job.save()
|
||||
if not job.pending_items.exists() and not job.complete:
|
||||
job.status = "complete"
|
||||
job.complete = True
|
||||
job.save(update_fields=["complete"])
|
||||
job.save(update_fields=["complete", "status"])
|
||||
|
||||
def resolve(self):
|
||||
"""try various ways to lookup a book"""
|
||||
|
|
Loading…
Reference in a new issue