faster edits
This commit is contained in:
parent
e666159811
commit
abf445b7f1
2 changed files with 17 additions and 14 deletions
|
@ -118,20 +118,21 @@ class MetaClip:
|
||||||
end = self.end
|
end = self.end
|
||||||
item = self.item
|
item = self.item
|
||||||
layers = {}
|
layers = {}
|
||||||
|
private = []
|
||||||
for l in settings.CONFIG['layers']:
|
for l in settings.CONFIG['layers']:
|
||||||
name = l['id']
|
name = l['id']
|
||||||
ll = layers.setdefault(name, [])
|
layers[name] = []
|
||||||
qs = Annotation.objects.filter(layer=name, item=item).order_by(
|
|
||||||
'start', 'end', 'sortvalue')
|
|
||||||
if name == 'subtitles':
|
|
||||||
qs = qs.exclude(value='')
|
|
||||||
qs = qs.filter(start__lt=end, end__gt=start)
|
|
||||||
if l.get('private'):
|
if l.get('private'):
|
||||||
if user and user.is_anonymous():
|
private.append(name)
|
||||||
user = None
|
qs = Annotation.objects.filter(item=item).exclude(value='')
|
||||||
qs = qs.filter(user=user)
|
qs = qs.order_by('start', 'end', 'sortvalue')
|
||||||
for a in qs.order_by('start'):
|
qs = qs.filter(start__lt=end, end__gt=start)
|
||||||
ll.append(a.json(user=user))
|
for a in qs.order_by('start'):
|
||||||
|
if a.layer in private:
|
||||||
|
if a.user == user:
|
||||||
|
layers[a.layer].append(a.json(user=user))
|
||||||
|
else:
|
||||||
|
layers[a.layer].append(a.json(user=user))
|
||||||
return layers
|
return layers
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -229,7 +229,8 @@ class Edit(models.Model):
|
||||||
clips_query = self.clip_query()
|
clips_query = self.clip_query()
|
||||||
if clips_query['conditions']:
|
if clips_query['conditions']:
|
||||||
clips = clip.models.Clip.objects.find({'query': clips_query}, user)
|
clips = clip.models.Clip.objects.find({'query': clips_query}, user)
|
||||||
clips = clips.filter(item__in=self.get_items(user))
|
items = [i['id'] for i in self.get_items(user).values('id')]
|
||||||
|
clips = clips.filter(item__in=items)
|
||||||
else:
|
else:
|
||||||
clips = None
|
clips = None
|
||||||
return clips
|
return clips
|
||||||
|
@ -272,9 +273,10 @@ class Edit(models.Model):
|
||||||
frames = []
|
frames = []
|
||||||
if not self.poster_frames:
|
if not self.poster_frames:
|
||||||
items = self.get_items(self.user).filter(rendered=True)
|
items = self.get_items(self.user).filter(rendered=True)
|
||||||
if 0 < items.count() <= 1000:
|
items_count = items.count()
|
||||||
|
if 0 < items_count <= 1000:
|
||||||
poster_frames = []
|
poster_frames = []
|
||||||
for i in range(0, items.count(), max(1, int(items.count()/4))):
|
for i in range(0, items_count, max(1, int(items_count/4))):
|
||||||
poster_frames.append({
|
poster_frames.append({
|
||||||
'item': items[int(i)].public_id,
|
'item': items[int(i)].public_id,
|
||||||
'position': items[int(i)].poster_frame
|
'position': items[int(i)].poster_frame
|
||||||
|
|
Loading…
Reference in a new issue