compute edit duration more efficiently
This commit is contained in:
parent
e084766e69
commit
8cb776eb51
1 changed files with 6 additions and 2 deletions
|
@ -316,7 +316,7 @@ class Edit(models.Model):
|
|||
_map = {
|
||||
'posterFrames': 'poster_frames'
|
||||
}
|
||||
if 'clips' in keys or 'duration' in keys:
|
||||
if 'clips' in keys:
|
||||
clips = self.get_clips_json(user)
|
||||
|
||||
for key in keys:
|
||||
|
@ -330,7 +330,11 @@ class Edit(models.Model):
|
|||
elif key == 'clips':
|
||||
response[key] = clips
|
||||
elif key == 'duration':
|
||||
response[key] = sum([c['duration'] for c in clips])
|
||||
if self.type == 'static':
|
||||
response[key] = sum([(c['annotation__end'] or c['end']) - (c['annotation__start'] or c['start'])
|
||||
for c in self.get_clips(user).values('start', 'end', 'annotation__start', 'annotation__end')])
|
||||
else:
|
||||
response[key] = sum([c['end'] - c['start'] for c in self.get_clips(user).values('start', 'end')])
|
||||
elif key == 'editable':
|
||||
response[key] = self.editable(user)
|
||||
elif key == 'user':
|
||||
|
|
Loading…
Reference in a new issue