forked from 0x2620/pandora
item should only be loaded if item is joined, disable for now
This commit is contained in:
parent
f4aa94f848
commit
72bb3ba6c1
3 changed files with 41 additions and 30 deletions
|
@ -145,7 +145,11 @@ class ClipManager(Manager):
|
|||
keys = layer_ids + ['annotations', 'text', '*']
|
||||
conditions = data.get('query', {}).get('conditions', [])
|
||||
conditions = flatten_conditions(conditions)
|
||||
conditions = list(filter(lambda c: c.get('key') in keys, conditions))
|
||||
conditions_ = []
|
||||
for c in conditions:
|
||||
if c.get('key') in keys and c not in conditions_:
|
||||
conditions_.append(c)
|
||||
conditions = conditions_
|
||||
operator = data.get('query', {}).get('operator', '&')
|
||||
|
||||
def parse(condition):
|
||||
|
|
|
@ -95,7 +95,7 @@ def findClips(request, data):
|
|||
if 'keys' in data:
|
||||
qs = order_query(qs, query['sort'])
|
||||
qs = qs[query['range'][0]:query['range'][1]]
|
||||
qs = qs.select_related('item')
|
||||
#qs = qs.select_related('item')
|
||||
|
||||
layers = settings.CONFIG['layers']
|
||||
entity_layer_ids = [k['id'] for k in layers if k['type'] == 'entity']
|
||||
|
|
|
@ -11,9 +11,10 @@ import tempfile
|
|||
from six.moves.urllib.parse import quote
|
||||
import ox
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.cache import cache
|
||||
from django.db import models, transaction
|
||||
from django.db.models import Max
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from oxdjango.fields import JSONField
|
||||
|
@ -118,7 +119,7 @@ class Edit(models.Model):
|
|||
c = self.add_clip(data)
|
||||
if c:
|
||||
ids.insert(index, c.id)
|
||||
added.append(c.json(user))
|
||||
added.append(c.json(user=user))
|
||||
added[-1]['index'] = index
|
||||
index += 1
|
||||
else:
|
||||
|
@ -488,6 +489,11 @@ class Clip(models.Model):
|
|||
self.sortvolume = 0
|
||||
|
||||
def json(self, user=None):
|
||||
cache_key = 'edit:clip:' + str(self.get_id())
|
||||
if user:
|
||||
cache_key += ':' + user.username
|
||||
data = cache.get(cache_key)
|
||||
if not data:
|
||||
data = {
|
||||
'id': self.get_id(),
|
||||
'index': self.index,
|
||||
|
@ -514,6 +520,7 @@ class Clip(models.Model):
|
|||
data['cuts'] = tuple([c for c in self.item.get('cuts', []) if c > self.start and c < self.end])
|
||||
data['layers'] = self.get_layers(user)
|
||||
data['streams'] = [s.file.oshash for s in self.item.streams()]
|
||||
cache.set(cache_key, data, 180)
|
||||
return data
|
||||
|
||||
def get_annotations(self):
|
||||
|
|
Loading…
Reference in a new issue