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,7 +999,10 @@ 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
|
||||
value = self.get(source)
|
||||
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)
|
||||
set_value(s, name, value)
|
||||
|
|
Loading…
Reference in a new issue