Merge branch 'master' of git.0x2620.org:/pandora
This commit is contained in:
commit
225b7cedbd
3 changed files with 16 additions and 7 deletions
|
@ -55,6 +55,8 @@ def get_info(url):
|
||||||
for k in info_keys
|
for k in info_keys
|
||||||
if k in i and i[k]
|
if k in i and i[k]
|
||||||
})
|
})
|
||||||
|
if not 'tags' in info[-1]:
|
||||||
|
info[-1]['tags'] = []
|
||||||
if 'upload_date' in i:
|
if 'upload_date' in i:
|
||||||
info[-1]['date'] = '-'.join([i['upload_date'][:4], i['upload_date'][4:6], i['upload_date'][6:]])
|
info[-1]['date'] = '-'.join([i['upload_date'][:4], i['upload_date'][4:6], i['upload_date'][6:]])
|
||||||
return info
|
return info
|
||||||
|
|
|
@ -135,6 +135,12 @@
|
||||||
{"id": "texts", "title": "Texts"},
|
{"id": "texts", "title": "Texts"},
|
||||||
{"id": "embeds", "title": "Embeds"}
|
{"id": "embeds", "title": "Embeds"}
|
||||||
],
|
],
|
||||||
|
"importMetadata": {
|
||||||
|
"date": "{date}",
|
||||||
|
"topic": "{tags}",
|
||||||
|
"summary": "{description}",
|
||||||
|
"title": "{title}"
|
||||||
|
},
|
||||||
/*
|
/*
|
||||||
"itemKeys" defines the metadata associated with each item. Required keys
|
"itemKeys" defines the metadata associated with each item. Required keys
|
||||||
are "*", "id" and "title". Annotation layers can be referenced too, which
|
are "*", "id" and "title". Annotation layers can be referenced too, which
|
||||||
|
|
|
@ -225,15 +225,18 @@ def find(request, data):
|
||||||
clips = qs
|
clips = qs
|
||||||
return [c.json(query['clip_keys'], query['clip_filter']) for c in clips]
|
return [c.json(query['clip_keys'], query['clip_filter']) for c in clips]
|
||||||
|
|
||||||
|
sort_keys = {
|
||||||
|
'accessed', 'modified', 'timesaccessed',
|
||||||
|
'numberofannotations', 'numberoffiles', 'numberofdocuments'
|
||||||
|
}
|
||||||
|
|
||||||
def only_p_sums(m):
|
def only_p_sums(m):
|
||||||
r = {}
|
r = {}
|
||||||
for p in _p:
|
for p in _p:
|
||||||
if p == 'accessed':
|
if p == 'accessed':
|
||||||
r[p] = m.sort.accessed or ''
|
r[p] = m.sort.accessed or ''
|
||||||
elif p == 'modified':
|
elif p in sort_keys:
|
||||||
r[p] = m.sort.modified
|
r[p] = getattr(m.sort, p)
|
||||||
elif p == 'timesaccessed':
|
|
||||||
r[p] = m.sort.timesaccessed
|
|
||||||
else:
|
else:
|
||||||
r[p] = m.json.get(p)
|
r[p] = m.json.get(p)
|
||||||
if 'clip_qs' in query:
|
if 'clip_qs' in query:
|
||||||
|
@ -252,9 +255,7 @@ def find(request, data):
|
||||||
return r
|
return r
|
||||||
qs = qs[query['range'][0]:query['range'][1]]
|
qs = qs[query['range'][0]:query['range'][1]]
|
||||||
# response['data']['items'] = [m.get_json(_p) for m in qs]
|
# response['data']['items'] = [m.get_json(_p) for m in qs]
|
||||||
if filter(lambda p: p in (
|
if any(p for p in _p if p in sort_keys):
|
||||||
'accessed', 'modified', 'timesaccessed', 'viewed'
|
|
||||||
), _p):
|
|
||||||
qs = qs.select_related()
|
qs = qs.select_related()
|
||||||
response['data']['items'] = [only_p_sums(m) for m in qs]
|
response['data']['items'] = [only_p_sums(m) for m in qs]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue