More efficient SQL query to compute import batch status

This commit is contained in:
Eliot Berriot 2018-04-21 16:02:11 +02:00
parent e29cfb7301
commit d98c33e5ed
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
2 changed files with 5 additions and 2 deletions

View file

@ -507,6 +507,8 @@ class ImportBatch(models.Model):
def update_status(self):
old_status = self.status
self.status = utils.compute_status(self.jobs.all())
if self.status == old_status:
return
self.save(update_fields=['status'])
if self.status != old_status and self.status == 'finished':
from . import tasks