forked from 0x2620/pandora
faster clip queries if keys include item keys
This commit is contained in:
parent
937b8c6b50
commit
4a67150604
2 changed files with 9 additions and 6 deletions
|
@ -40,11 +40,11 @@ class MetaClip:
|
||||||
setattr(self, l, self.annotations.filter(layer=l).count()>0)
|
setattr(self, l, self.annotations.filter(layer=l).count()>0)
|
||||||
models.Model.save(self, *args, **kwargs)
|
models.Model.save(self, *args, **kwargs)
|
||||||
|
|
||||||
|
clip_keys = ('id', 'in', 'out', 'position', 'created', 'modified',
|
||||||
|
'hue', 'saturation', 'lightness', 'volume', 'videoRatio')
|
||||||
def json(self, keys=None):
|
def json(self, keys=None):
|
||||||
j = {}
|
j = {}
|
||||||
clip_keys = ('id', 'in', 'out', 'position', 'created', 'modified',
|
for key in self.clip_keys:
|
||||||
'hue', 'saturation', 'lightness', 'volume', 'videoRatio')
|
|
||||||
for key in clip_keys:
|
|
||||||
j[key] = getattr(self, {
|
j[key] = getattr(self, {
|
||||||
'id': 'public_id',
|
'id': 'public_id',
|
||||||
'in': 'start',
|
'in': 'start',
|
||||||
|
@ -61,7 +61,7 @@ class MetaClip:
|
||||||
j['annotations'] = [a.json(keys=['value', 'id', 'layer'])
|
j['annotations'] = [a.json(keys=['value', 'id', 'layer'])
|
||||||
for a in self.annotations.filter(layer__in=self.layers)]
|
for a in self.annotations.filter(layer__in=self.layers)]
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if key not in clip_keys and key not in j:
|
if key not in self.clip_keys and key not in j:
|
||||||
value = self.item.get(key)
|
value = self.item.get(key)
|
||||||
if not value and hasattr(self.item.sort, key):
|
if not value and hasattr(self.item.sort, key):
|
||||||
value = getattr(self.item.sort, key)
|
value = getattr(self.item.sort, key)
|
||||||
|
|
|
@ -35,7 +35,7 @@ def order_query(qs, sort):
|
||||||
if operator != '-':
|
if operator != '-':
|
||||||
operator = ''
|
operator = ''
|
||||||
clip_keys = ('public_id', 'start', 'end', 'hue', 'saturation', 'lightness', 'volume',
|
clip_keys = ('public_id', 'start', 'end', 'hue', 'saturation', 'lightness', 'volume',
|
||||||
'annotations__sortvalue', 'videoRatio',
|
'duration', 'annotations__sortvalue', 'videoRatio',
|
||||||
'director', 'title')
|
'director', 'title')
|
||||||
key = {
|
key = {
|
||||||
'id': 'public_id',
|
'id': 'public_id',
|
||||||
|
@ -82,9 +82,12 @@ def findClips(request):
|
||||||
if 'keys' in data:
|
if 'keys' in data:
|
||||||
qs = order_query(qs, query['sort'])
|
qs = order_query(qs, query['sort'])
|
||||||
qs = qs[query['range'][0]:query['range'][1]]
|
qs = qs[query['range'][0]:query['range'][1]]
|
||||||
#qs = qs.select_related('item__sort')
|
|
||||||
ids = []
|
ids = []
|
||||||
keys = filter(lambda k: k not in models.Clip.layers, data['keys'])
|
keys = filter(lambda k: k not in models.Clip.layers, data['keys'])
|
||||||
|
if filter(lambda k: k not in models.Clip.clip_keys, keys):
|
||||||
|
qs = qs.select_related('item__sort')
|
||||||
|
|
||||||
def add(p):
|
def add(p):
|
||||||
ids.append(p.id)
|
ids.append(p.id)
|
||||||
return p.json(keys=keys)
|
return p.json(keys=keys)
|
||||||
|
|
Loading…
Reference in a new issue