forked from 0x2620/pandora
add option to sort by number of annotations per layer
This commit is contained in:
parent
ace04688f2
commit
fd2992c588
2 changed files with 12 additions and 1 deletions
|
@ -578,6 +578,14 @@
|
|||
"sort": true,
|
||||
"value": {"layer": "subtitles", "type": "wordsperminute"}
|
||||
},
|
||||
{
|
||||
"id": "numberofnotes",
|
||||
"title": "Number of Notes",
|
||||
"type": "integer",
|
||||
"columnWidth": 60,
|
||||
"sort": true,
|
||||
"value": {"layer": "notes", "type": "length"}
|
||||
},
|
||||
{
|
||||
"id": "numberofdocuments",
|
||||
"title": "Number of Documents",
|
||||
|
|
|
@ -999,6 +999,9 @@ class Item(models.Model):
|
|||
set_value(s, name, value)
|
||||
elif sort_type in ('length', 'integer', 'time', 'float'):
|
||||
#can be length of strings or length of arrays, i.e. keywords
|
||||
if 'layer' in key.get('value', []):
|
||||
value = self.annotations.filter(layer=key['value']['layer']).count()
|
||||
else:
|
||||
value = self.get(source)
|
||||
if isinstance(value, list):
|
||||
value = len(value)
|
||||
|
|
Loading…
Reference in a new issue