forked from 0x2620/pandora
itemsQuery/clipsQuery
This commit is contained in:
parent
867bff4e10
commit
80ade383f9
11 changed files with 45 additions and 45 deletions
|
@ -27,8 +27,8 @@ def parse_query(data, user):
|
||||||
if key in data:
|
if key in data:
|
||||||
query[key] = data[key]
|
query[key] = data[key]
|
||||||
query['qs'] = models.Annotation.objects.find(query, user)
|
query['qs'] = models.Annotation.objects.find(query, user)
|
||||||
if 'itemQuery' in data:
|
if 'itemsQuery' in data:
|
||||||
item_query = Item.objects.find({'query': data['itemQuery']}, user)
|
item_query = Item.objects.find({'query': data['itemsQuery']}, user)
|
||||||
query['qs'] = query['qs'].filter(item__in=item_query)
|
query['qs'] = query['qs'].filter(item__in=item_query)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ def findAnnotations(request):
|
||||||
'''
|
'''
|
||||||
param data {
|
param data {
|
||||||
query: ...
|
query: ...
|
||||||
itemQuery: ...
|
itemsQuery: ...
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -20,8 +20,8 @@ def parse_query(data, user):
|
||||||
if key in data:
|
if key in data:
|
||||||
query[key] = data[key]
|
query[key] = data[key]
|
||||||
query['qs'] = models.Clip.objects.find(query, user)
|
query['qs'] = models.Clip.objects.find(query, user)
|
||||||
if 'itemQuery' in data and data['itemQuery'].get('conditions'):
|
if 'itemsQuery' in data and data['itemsQuery'].get('conditions'):
|
||||||
item_query = Item.objects.find({'query': data['itemQuery']}, user)
|
item_query = Item.objects.find({'query': data['itemsQuery']}, user)
|
||||||
query['qs'] = query['qs'].filter(item__in=item_query)
|
query['qs'] = query['qs'].filter(item__in=item_query)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ def findClips(request):
|
||||||
'''
|
'''
|
||||||
param data {
|
param data {
|
||||||
query: ...
|
query: ...
|
||||||
itemQuery: ...
|
itemsQuery: ...
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -127,8 +127,8 @@ def parse_query(data, user):
|
||||||
if key in data:
|
if key in data:
|
||||||
query[key] = data[key]
|
query[key] = data[key]
|
||||||
query['qs'] = models.Event.objects.find(query, user)
|
query['qs'] = models.Event.objects.find(query, user)
|
||||||
if 'itemQuery' in data:
|
if 'itemsQuery' in data:
|
||||||
item_query = models.Item.objects.find({'query': data['itemQuery']}, user)
|
item_query = models.Item.objects.find({'query': data['itemsQuery']}, user)
|
||||||
query['qs'] = query['qs'].filter(items__in=item_query)
|
query['qs'] = query['qs'].filter(items__in=item_query)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ def findEvents(request):
|
||||||
|
|
||||||
query: query object, more on query syntax at
|
query: query object, more on query syntax at
|
||||||
https://wiki.0x2620.org/wiki/pandora/QuerySyntax
|
https://wiki.0x2620.org/wiki/pandora/QuerySyntax
|
||||||
itemQuery: {
|
itemsQuery: {
|
||||||
//see find request
|
//see find request
|
||||||
},
|
},
|
||||||
sort: array of key, operator dics
|
sort: array of key, operator dics
|
||||||
|
@ -170,7 +170,7 @@ def findEvents(request):
|
||||||
]
|
]
|
||||||
range: result range, array [from, to]
|
range: result range, array [from, to]
|
||||||
|
|
||||||
itemQuery can be used to limit the resuts to matches in those items.
|
itemsQuery can be used to limit the resuts to matches in those items.
|
||||||
|
|
||||||
with keys, items is list of dicts with requested properties:
|
with keys, items is list of dicts with requested properties:
|
||||||
return {'status': {'code': int, 'text': string},
|
return {'status': {'code': int, 'text': string},
|
||||||
|
|
|
@ -91,10 +91,10 @@ def parse_query(data, user):
|
||||||
query[key] = data[key]
|
query[key] = data[key]
|
||||||
query['qs'] = models.Item.objects.find(data, user)
|
query['qs'] = models.Item.objects.find(data, user)
|
||||||
|
|
||||||
if 'clipQuery' in data:
|
if 'clipsQuery' in data:
|
||||||
query['clip_qs'] = Clip.objects.find({'query': data['clipQuery']}, user).order_by('start')
|
query['clip_qs'] = Clip.objects.find({'query': data['clipsQuery']}, user).order_by('start')
|
||||||
query['clip_items'] = data['clipQuery'].get('items', 5)
|
query['clip_items'] = data['clipsQuery'].get('items', 5)
|
||||||
query['clip_keys'] = data['clipQuery'].get('keys', ['id', 'in', 'out', 'annotations'])
|
query['clip_keys'] = data['clipsQuery'].get('keys', ['id', 'in', 'out', 'annotations'])
|
||||||
|
|
||||||
#group by only allows sorting by name or number of itmes
|
#group by only allows sorting by name or number of itmes
|
||||||
return query
|
return query
|
||||||
|
@ -105,7 +105,7 @@ def find(request):
|
||||||
'query': query,
|
'query': query,
|
||||||
'sort': array,
|
'sort': array,
|
||||||
'range': array
|
'range': array
|
||||||
clipQuery: ...
|
clipsQuery: ...
|
||||||
}
|
}
|
||||||
|
|
||||||
query: query object, more on query syntax at
|
query: query object, more on query syntax at
|
||||||
|
|
|
@ -27,8 +27,8 @@ def parse_query(data, user):
|
||||||
if key in data:
|
if key in data:
|
||||||
query[key] = data[key]
|
query[key] = data[key]
|
||||||
query['qs'] = models.News.objects.find(query, user)
|
query['qs'] = models.News.objects.find(query, user)
|
||||||
if 'itemQuery' in data:
|
if 'itemsQuery' in data:
|
||||||
item_query = Item.objects.find({'query': data['itemQuery']}, user)
|
item_query = Item.objects.find({'query': data['itemsQuery']}, user)
|
||||||
query['qs'] = query['qs'].filter(item__in=item_query)
|
query['qs'] = query['qs'].filter(item__in=item_query)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ def findNews(request):
|
||||||
'''
|
'''
|
||||||
param data {
|
param data {
|
||||||
query: ...
|
query: ...
|
||||||
itemQuery: ...
|
itemsQuery: ...
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -43,8 +43,8 @@ def parse_query(data, user):
|
||||||
if key in data:
|
if key in data:
|
||||||
query[key] = data[key]
|
query[key] = data[key]
|
||||||
query['qs'] = models.Person.objects.find(query, user)
|
query['qs'] = models.Person.objects.find(query, user)
|
||||||
#if 'itemQuery' in data:
|
#if 'itemsQuery' in data:
|
||||||
# item_query = models.Item.objects.find({'query': data['itemQuery']}, user)
|
# item_query = models.Item.objects.find({'query': data['itemsQuery']}, user)
|
||||||
# query['qs'] = query['qs'].filter(items__in=item_query)
|
# query['qs'] = query['qs'].filter(items__in=item_query)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ def findNames(request):
|
||||||
]
|
]
|
||||||
operator: ","
|
operator: ","
|
||||||
},
|
},
|
||||||
itemQuery: {
|
itemsQuery: {
|
||||||
//see find request
|
//see find request
|
||||||
},
|
},
|
||||||
sort: [{key: 'name', operator: '+'}],
|
sort: [{key: 'name', operator: '+'}],
|
||||||
|
|
|
@ -148,8 +148,8 @@ def parse_query(data, user):
|
||||||
if key in data:
|
if key in data:
|
||||||
query[key] = data[key]
|
query[key] = data[key]
|
||||||
query['qs'] = models.Place.objects.find(query, user)
|
query['qs'] = models.Place.objects.find(query, user)
|
||||||
if 'itemQuery' in data:
|
if 'itemsQuery' in data:
|
||||||
item_query = models.Item.objects.find({'query': data['itemQuery']}, user)
|
item_query = models.Item.objects.find({'query': data['itemsQuery']}, user)
|
||||||
query['qs'] = query['qs'].filter(items__in=item_query)
|
query['qs'] = query['qs'].filter(items__in=item_query)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ def findPlaces(request):
|
||||||
]
|
]
|
||||||
operator: ","
|
operator: ","
|
||||||
},
|
},
|
||||||
itemQuery: {
|
itemsQuery: {
|
||||||
//see find request
|
//see find request
|
||||||
},
|
},
|
||||||
sort: [{key: 'name', operator: '+'}],
|
sort: [{key: 'name', operator: '+'}],
|
||||||
|
@ -193,7 +193,7 @@ def findPlaces(request):
|
||||||
possible query keys:
|
possible query keys:
|
||||||
name, geoname, user
|
name, geoname, user
|
||||||
|
|
||||||
itemQuery can be used to limit the resuts to matches in those items.
|
itemsQuery can be used to limit the resuts to matches in those items.
|
||||||
Uses the same query syntax as used in the find request.
|
Uses the same query syntax as used in the find request.
|
||||||
|
|
||||||
possible keys:
|
possible keys:
|
||||||
|
|
|
@ -45,8 +45,8 @@ def parse_query(data, user):
|
||||||
if key in data:
|
if key in data:
|
||||||
query[key] = data[key]
|
query[key] = data[key]
|
||||||
query['qs'] = models.Title.objects.find(query, user)
|
query['qs'] = models.Title.objects.find(query, user)
|
||||||
#if 'itemQuery' in data:
|
#if 'itemsQuery' in data:
|
||||||
# item_query = models.Item.objects.find({'query': data['itemQuery']}, user)
|
# item_query = models.Item.objects.find({'query': data['itemsQuery']}, user)
|
||||||
# query['qs'] = query['qs'].filter(items__in=item_query)
|
# query['qs'] = query['qs'].filter(items__in=item_query)
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ def findTitles(request):
|
||||||
]
|
]
|
||||||
operator: ","
|
operator: ","
|
||||||
},
|
},
|
||||||
itemQuery: {
|
itemsQuery: {
|
||||||
//see find request
|
//see find request
|
||||||
},
|
},
|
||||||
sort: [{key: 'title', operator: '+'}],
|
sort: [{key: 'title', operator: '+'}],
|
||||||
|
|
|
@ -48,19 +48,19 @@ pandora.ui.clipList = function(videoRatio) {
|
||||||
callback({data: {items: []}});
|
callback({data: {items: []}});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var itemQuery, query;
|
var itemsQuery, query;
|
||||||
if (!ui.item) {
|
if (!ui.item) {
|
||||||
itemQuery = ui.find;
|
itemsQuery = ui.find;
|
||||||
query = {conditions: [], operator: '&'};
|
query = {conditions: [], operator: '&'};
|
||||||
// if the item query contains a layer condition,
|
// if the item query contains a layer condition,
|
||||||
// then this condition is added to the clip query
|
// then this condition is added to the clip query
|
||||||
itemQuery.conditions.forEach(function(condition) {
|
itemsQuery.conditions.forEach(function(condition) {
|
||||||
if (Ox.getPositionById(pandora.site.layers, condition.key) > -1) {
|
if (Ox.getPositionById(pandora.site.layers, condition.key) > -1) {
|
||||||
query.conditions.push(condition);
|
query.conditions.push(condition);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
itemQuery = {
|
itemsQuery = {
|
||||||
conditions:[{key: 'id', value: ui.item, operator: '=='}],
|
conditions:[{key: 'id', value: ui.item, operator: '=='}],
|
||||||
operator: '&'
|
operator: '&'
|
||||||
};
|
};
|
||||||
|
@ -69,7 +69,7 @@ pandora.ui.clipList = function(videoRatio) {
|
||||||
query = {conditions: [], operator: '&'};
|
query = {conditions: [], operator: '&'};
|
||||||
}
|
}
|
||||||
pandora.api.findClips(Ox.extend({
|
pandora.api.findClips(Ox.extend({
|
||||||
itemQuery: itemQuery,
|
itemsQuery: itemsQuery,
|
||||||
query: query
|
query: query
|
||||||
}, data), callback);
|
}, data), callback);
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,17 +11,17 @@ pandora.ui.clipPlayer = function() {
|
||||||
video: function(range, callback) {
|
video: function(range, callback) {
|
||||||
var callback = arguments[arguments.length - 1],
|
var callback = arguments[arguments.length - 1],
|
||||||
range = arguments.length == 2 ? arguments[0] : null,
|
range = arguments.length == 2 ? arguments[0] : null,
|
||||||
itemQuery = pandora.user.ui.find,
|
itemsQuery = pandora.user.ui.find,
|
||||||
query = {conditions:[]};
|
query = {conditions:[]};
|
||||||
//fixme: can this be in pandora.Query? dont just check for subtitles
|
//fixme: can this be in pandora.Query? dont just check for subtitles
|
||||||
itemQuery.conditions.forEach(function(q) {
|
itemsQuery.conditions.forEach(function(q) {
|
||||||
if (q.key == 'subtitles') {
|
if (q.key == 'subtitles') {
|
||||||
query.conditions.push({key: 'subtitles', value: q.value, operator: q.operator});
|
query.conditions.push({key: 'subtitles', value: q.value, operator: q.operator});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pandora.api.findClips(Ox.extend({
|
pandora.api.findClips(Ox.extend({
|
||||||
query: query,
|
query: query,
|
||||||
itemQuery: itemQuery
|
itemsQuery: itemsQuery
|
||||||
}, range ? {
|
}, range ? {
|
||||||
keys: ['id', 'in', 'out', 'subtitles'],
|
keys: ['id', 'in', 'out', 'subtitles'],
|
||||||
range: range,
|
range: range,
|
||||||
|
|
|
@ -146,17 +146,17 @@ pandora.ui.navigationView = function(type, videoRatio) {
|
||||||
// 20 menu + 24 toolbar + 1 resizebar + 16 statusbar
|
// 20 menu + 24 toolbar + 1 resizebar + 16 statusbar
|
||||||
height: window.innerHeight - ui.showGroups * ui.groupsSize - 61,
|
height: window.innerHeight - ui.showGroups * ui.groupsSize - 61,
|
||||||
places: function(data, callback) {
|
places: function(data, callback) {
|
||||||
var itemQuery;
|
var itemsQuery;
|
||||||
if (!ui.item) {
|
if (!ui.item) {
|
||||||
itemQuery = ui.find;
|
itemsQuery = ui.find;
|
||||||
} else {
|
} else {
|
||||||
itemQuery = {
|
itemsQuery = {
|
||||||
conditions: [{key: 'id', value: ui.item, operator: '=='}],
|
conditions: [{key: 'id', value: ui.item, operator: '=='}],
|
||||||
operator: '&'
|
operator: '&'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return pandora.api.findPlaces(Ox.extend({
|
return pandora.api.findPlaces(Ox.extend({
|
||||||
itemQuery: itemQuery
|
itemsQuery: itemsQuery
|
||||||
}, data), callback);
|
}, data), callback);
|
||||||
},
|
},
|
||||||
selected: ui.mapSelection,
|
selected: ui.mapSelection,
|
||||||
|
@ -186,7 +186,7 @@ pandora.ui.navigationView = function(type, videoRatio) {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
pandora.api.findEvents({
|
pandora.api.findEvents({
|
||||||
itemQuery: !ui.item ? ui.find : {
|
itemsQuery: !ui.item ? ui.find : {
|
||||||
conditions: [{key: 'id', value: ui.item, operator: '=='}],
|
conditions: [{key: 'id', value: ui.item, operator: '=='}],
|
||||||
operator: '&'
|
operator: '&'
|
||||||
},
|
},
|
||||||
|
@ -233,17 +233,17 @@ pandora.ui.navigationView = function(type, videoRatio) {
|
||||||
$status.html('loading...');
|
$status.html('loading...');
|
||||||
$list.options({
|
$list.options({
|
||||||
items: function(data, callback) {
|
items: function(data, callback) {
|
||||||
var itemQuery;
|
var itemsQuery;
|
||||||
if (!ui.item) {
|
if (!ui.item) {
|
||||||
itemQuery = ui.find;
|
itemsQuery = ui.find;
|
||||||
} else {
|
} else {
|
||||||
itemQuery = {
|
itemsQuery = {
|
||||||
conditions: [{key: 'id', value: ui.item, operator: '=='}],
|
conditions: [{key: 'id', value: ui.item, operator: '=='}],
|
||||||
operator: '&'
|
operator: '&'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return pandora.api.findClips(Ox.extend({
|
return pandora.api.findClips(Ox.extend({
|
||||||
itemQuery: itemQuery,
|
itemsQuery: itemsQuery,
|
||||||
query: {
|
query: {
|
||||||
conditions: [{key: itemName, value: id, operator:'=='}],
|
conditions: [{key: itemName, value: id, operator:'=='}],
|
||||||
operator: '&'
|
operator: '&'
|
||||||
|
|
Loading…
Reference in a new issue