1
0
Fork 0
mirror of synced 2024-06-26 10:00:19 +12:00

speed up latest_title by preferring db title if present

This commit is contained in:
Nick Sweeting 2021-02-16 15:49:53 -05:00
parent 8b236b9367
commit 1e2188517b

View file

@ -169,11 +169,20 @@ class Snapshot(models.Model):
@cached_property
def latest_title(self):
if self.title:
return self.title
try:
return self.archiveresult_set.filter(extractor='title', status='succeeded')[0].output
except ArchiveResult.DoesNotExist:
pass
if ('title' in self.history
and self.history['title']
and (self.history['title'][-1].status == 'succeeded')
and self.history['title'][-1].output.strip()):
return self.history['title'][-1].output.strip()
return None
def save_tags(self, tags=()):