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:
|
else:
|
||||||
conn.append(parseCondition(condition, user))
|
conn.append(parseCondition(condition, user))
|
||||||
if conn:
|
if conn:
|
||||||
|
if operator == '|':
|
||||||
q = conn[0]
|
q = conn[0]
|
||||||
for c in conn[1:]:
|
for c in conn[1:]:
|
||||||
if operator == '|':
|
|
||||||
q = q | c
|
q = q | c
|
||||||
|
return [q]
|
||||||
else:
|
else:
|
||||||
q = q & c
|
return conn
|
||||||
return q
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class ClipManager(Manager):
|
class ClipManager(Manager):
|
||||||
|
@ -149,12 +149,15 @@ class ClipManager(Manager):
|
||||||
|
|
||||||
conditions = [parse(c) for c in conditions]
|
conditions = [parse(c) for c in conditions]
|
||||||
if 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]
|
q = conditions[0]
|
||||||
for c in conditions[1:]:
|
for c in conditions[1:]:
|
||||||
if operator == '|':
|
|
||||||
q = q | c
|
q = q | c
|
||||||
|
return [q]
|
||||||
else:
|
else:
|
||||||
q = q & c
|
return conditions
|
||||||
return q
|
return q
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -187,7 +190,8 @@ class ClipManager(Manager):
|
||||||
data.get('query', {}).get('operator', '&'),
|
data.get('query', {}).get('operator', '&'),
|
||||||
user)
|
user)
|
||||||
if conditions:
|
if conditions:
|
||||||
qs = qs.filter(conditions)
|
for condition in conditions:
|
||||||
|
qs = qs.filter(condition)
|
||||||
|
|
||||||
qs = qs.distinct()
|
qs = qs.distinct()
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,8 @@ def findClips(request, data):
|
||||||
def add_annotations(key, qs, add_layer=False):
|
def add_annotations(key, qs, add_layer=False):
|
||||||
values = ['public_id', 'layer', 'value', 'clip_id']
|
values = ['public_id', 'layer', 'value', 'clip_id']
|
||||||
if query['filter']:
|
if query['filter']:
|
||||||
qs = qs.filter(query['filter'])
|
for limit in query['filter']:
|
||||||
|
qs = qs.filter(limit)
|
||||||
for i in response['data']['items']:
|
for i in response['data']['items']:
|
||||||
if not key in i:
|
if not key in i:
|
||||||
i[key] = []
|
i[key] = []
|
||||||
|
|
Loading…
Reference in a new issue