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)
|
||||
models.Model.save(self, *args, **kwargs)
|
||||
|
||||
def json(self, keys=None):
|
||||
j = {}
|
||||
clip_keys = ('id', 'in', 'out', 'position', 'created', 'modified',
|
||||
'hue', 'saturation', 'lightness', 'volume', 'videoRatio')
|
||||
for key in clip_keys:
|
||||
def json(self, keys=None):
|
||||
j = {}
|
||||
for key in self.clip_keys:
|
||||
j[key] = getattr(self, {
|
||||
'id': 'public_id',
|
||||
'in': 'start',
|
||||
|
@ -61,7 +61,7 @@ class MetaClip:
|
|||
j['annotations'] = [a.json(keys=['value', 'id', 'layer'])
|
||||
for a in self.annotations.filter(layer__in=self.layers)]
|
||||
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)
|
||||
if not value and hasattr(self.item.sort, key):
|
||||
value = getattr(self.item.sort, key)
|
||||
|
|
|
@ -35,7 +35,7 @@ def order_query(qs, sort):
|
|||
if operator != '-':
|
||||
operator = ''
|
||||
clip_keys = ('public_id', 'start', 'end', 'hue', 'saturation', 'lightness', 'volume',
|
||||
'annotations__sortvalue', 'videoRatio',
|
||||
'duration', 'annotations__sortvalue', 'videoRatio',
|
||||
'director', 'title')
|
||||
key = {
|
||||
'id': 'public_id',
|
||||
|
@ -82,9 +82,12 @@ def findClips(request):
|
|||
if 'keys' in data:
|
||||
qs = order_query(qs, query['sort'])
|
||||
qs = qs[query['range'][0]:query['range'][1]]
|
||||
#qs = qs.select_related('item__sort')
|
||||
|
||||
ids = []
|
||||
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):
|
||||
ids.append(p.id)
|
||||
return p.json(keys=keys)
|
||||
|
|
Loading…
Reference in a new issue