mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +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)
|
task = import_item_task.delay(item)
|
||||||
item.task_id = task.id
|
item.task_id = task.id
|
||||||
item.save()
|
item.save()
|
||||||
|
job.status = "active"
|
||||||
|
job.save()
|
||||||
|
|
||||||
|
|
||||||
@app.task(queue="low_priority")
|
@app.task(queue="low_priority")
|
||||||
|
|
|
@ -6,13 +6,23 @@ from django.db import migrations, models
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('bookwyrm', '0160_auto_20221105_2030'),
|
("bookwyrm", "0160_auto_20221105_2030"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='importjob',
|
model_name="importjob",
|
||||||
name='status',
|
name="status",
|
||||||
field=models.CharField(choices=[('pending', 'Pending'), ('active', 'Active'), ('complete', 'Complete'), ('stopped', 'Stopped')], default='pending', max_length=50, null=True),
|
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.updated_date = timezone.now()
|
||||||
job.save()
|
job.save()
|
||||||
if not job.pending_items.exists() and not job.complete:
|
if not job.pending_items.exists() and not job.complete:
|
||||||
|
job.status = "complete"
|
||||||
job.complete = True
|
job.complete = True
|
||||||
job.save(update_fields=["complete"])
|
job.save(update_fields=["complete", "status"])
|
||||||
|
|
||||||
def resolve(self):
|
def resolve(self):
|
||||||
"""try various ways to lookup a book"""
|
"""try various ways to lookup a book"""
|
||||||
|
|
Loading…
Reference in a new issue