forked from 0x2620/pandora
fix findClips to return clips with annotations matching all conditions
This commit is contained in:
parent
f818f962bc
commit
0c99cbfaac
2 changed files with 18 additions and 13 deletions
|
@ -116,13 +116,13 @@ def parseConditions(conditions, operator, user):
|
|||
else:
|
||||
conn.append(parseCondition(condition, user))
|
||||
if conn:
|
||||
if operator == '|':
|
||||
q = conn[0]
|
||||
for c in conn[1:]:
|
||||
if operator == '|':
|
||||
q = q | c
|
||||
return [q]
|
||||
else:
|
||||
q = q & c
|
||||
return q
|
||||
return conn
|
||||
return None
|
||||
|
||||
class ClipManager(Manager):
|
||||
|
@ -149,12 +149,15 @@ class ClipManager(Manager):
|
|||
|
||||
conditions = [parse(c) for c in conditions]
|
||||
if conditions:
|
||||
# always make an any query,
|
||||
# since & is for intersection in clip not intersection in annotation
|
||||
if operator == '|' or operator == '&':
|
||||
q = conditions[0]
|
||||
for c in conditions[1:]:
|
||||
if operator == '|':
|
||||
q = q | c
|
||||
return [q]
|
||||
else:
|
||||
q = q & c
|
||||
return conditions
|
||||
return q
|
||||
return None
|
||||
|
||||
|
@ -187,7 +190,8 @@ class ClipManager(Manager):
|
|||
data.get('query', {}).get('operator', '&'),
|
||||
user)
|
||||
if conditions:
|
||||
qs = qs.filter(conditions)
|
||||
for condition in conditions:
|
||||
qs = qs.filter(condition)
|
||||
|
||||
qs = qs.distinct()
|
||||
|
||||
|
|
|
@ -117,7 +117,8 @@ def findClips(request, data):
|
|||
def add_annotations(key, qs, add_layer=False):
|
||||
values = ['public_id', 'layer', 'value', 'clip_id']
|
||||
if query['filter']:
|
||||
qs = qs.filter(query['filter'])
|
||||
for limit in query['filter']:
|
||||
qs = qs.filter(limit)
|
||||
for i in response['data']['items']:
|
||||
if not key in i:
|
||||
i[key] = []
|
||||
|
|
Loading…
Reference in a new issue