slightly faster filter update
This commit is contained in:
parent
e27e429fd6
commit
62c0c9337f
1 changed files with 10 additions and 13 deletions
|
@ -460,20 +460,17 @@ def migrate_10():
|
||||||
from item.person import get_sort_name
|
from item.person import get_sort_name
|
||||||
import unicodedata
|
import unicodedata
|
||||||
sort_names = {}
|
sort_names = {}
|
||||||
for f in Find.query.filter(Find.key.in_(Item.sort_keys)):
|
for f in Find.query.filter(Find.key.in_(Item.filter_keys)):
|
||||||
if f.key in Item.filter_keys:
|
sort_type = get_by_id(settings.config['itemKeys'], f.key).get('sortType')
|
||||||
sort_type = get_by_id(settings.config['itemKeys'], f.key).get('sortType')
|
if sort_type == 'person':
|
||||||
if sort_type == 'person':
|
if f.value in sort_names:
|
||||||
if f.value in sort_names:
|
f.sortvalue = sort_names[f.value]
|
||||||
f.sortvalue = sort_names[f.value]
|
|
||||||
else:
|
|
||||||
f.sortvalue = sort_names[f.value] = get_sort_name(f.value)
|
|
||||||
else:
|
else:
|
||||||
f.sortvalue = f.value
|
f.sortvalue = sort_names[f.value] = get_sort_name(f.value)
|
||||||
if f.sortvalue:
|
else:
|
||||||
f.sortvalue = unicodedata.normalize('NFKD', f.sortvalue).lower()
|
f.sortvalue = f.value
|
||||||
else:
|
if f.sortvalue:
|
||||||
f.sortvalue = None
|
f.sortvalue = unicodedata.normalize('NFKD', f.sortvalue).lower()
|
||||||
else:
|
else:
|
||||||
f.sortvalue = None
|
f.sortvalue = None
|
||||||
session.add(f)
|
session.add(f)
|
||||||
|
|
Loading…
Reference in a new issue