forked from 0x2620/pandora
Annotation.json: reduce repeated layer lookups
It's actually quite costly to look up keys in CONFIG, particularly inside a loop: this trims ~5% off get(keys=['layers']) for annotation-heavy items.
This commit is contained in:
parent
3f5be0bd27
commit
af0d87b569
1 changed files with 7 additions and 8 deletions
|
@ -98,7 +98,7 @@ class Annotation(models.Model):
|
||||||
value = models.TextField()
|
value = models.TextField()
|
||||||
findvalue = models.TextField(null=True)
|
findvalue = models.TextField(null=True)
|
||||||
sortvalue = models.CharField(max_length=1000, null=True, blank=True, db_index=True)
|
sortvalue = models.CharField(max_length=1000, null=True, blank=True, db_index=True)
|
||||||
|
|
||||||
languages = models.CharField(max_length=255, null=True, blank=True)
|
languages = models.CharField(max_length=255, null=True, blank=True)
|
||||||
|
|
||||||
def editable(self, user):
|
def editable(self, user):
|
||||||
|
@ -138,8 +138,7 @@ class Annotation(models.Model):
|
||||||
|
|
||||||
findvalue = self.value
|
findvalue = self.value
|
||||||
try:
|
try:
|
||||||
l = self.get_layer()
|
if layer['type'] == 'entity':
|
||||||
if l['type'] == 'entity':
|
|
||||||
findvalue = self.get_entity().name
|
findvalue = self.get_entity().name
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -232,7 +231,7 @@ class Annotation(models.Model):
|
||||||
|
|
||||||
annotation_keys = (
|
annotation_keys = (
|
||||||
'id', 'in', 'out', 'value', 'created', 'modified',
|
'id', 'in', 'out', 'value', 'created', 'modified',
|
||||||
'duration', 'layer', 'item', 'videoRatio', 'languages',
|
'duration', 'layer', 'item', 'videoRatio', 'languages',
|
||||||
'entity', 'event', 'place'
|
'entity', 'event', 'place'
|
||||||
)
|
)
|
||||||
_clip_keys = ('hue', 'lightness', 'saturation', 'volume')
|
_clip_keys = ('hue', 'lightness', 'saturation', 'volume')
|
||||||
|
@ -295,10 +294,10 @@ class Annotation(models.Model):
|
||||||
value = getattr(self.item.sort, key)
|
value = getattr(self.item.sort, key)
|
||||||
if value != None:
|
if value != None:
|
||||||
j[key] = value
|
j[key] = value
|
||||||
subtitles = get_by_key(settings.CONFIG['layers'], 'isSubtitles', True)
|
|
||||||
if subtitles:
|
if l.get('isSubtitles') and 'id' in j and not self.value:
|
||||||
if 'id' in j and self.layer == subtitles['id'] and not self.value:
|
del j['id']
|
||||||
del j['id']
|
|
||||||
return j
|
return j
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
|
Loading…
Reference in a new issue