1
0
Fork 0
mirror of synced 2024-06-29 03:20:58 +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 @cached_property
def latest_title(self): 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 if ('title' in self.history
and self.history['title'] and self.history['title']
and (self.history['title'][-1].status == 'succeeded') and (self.history['title'][-1].status == 'succeeded')
and self.history['title'][-1].output.strip()): and self.history['title'][-1].output.strip()):
return self.history['title'][-1].output.strip() return self.history['title'][-1].output.strip()
return None return None
def save_tags(self, tags=()): def save_tags(self, tags=()):