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

@ -53,10 +53,11 @@ def guess_mimetype(f):
def compute_status(jobs):
errored = any([job.status == 'errored' for job in jobs])
statuses = jobs.values_list('status', flat=True).distinct()
errored = any([status == 'errored' for status in statuses])
if errored:
return 'errored'
pending = any([job.status == 'pending' for job in jobs])
pending = any([status == 'pending' for status in statuses])
if pending:
return 'pending'
return 'finished'