Quote:
Originally Posted by Comfy.n
Ah, nice. I did as you suggested on a subset of the library containing only epub format and language:english (VL). Then I ran the template search and let it run for some minutes... then it returned the results containing author notes.
Thanks!
|
I found a linear search in the API I used, which is why it is taking forever. There is an alternate API that avoids that problem.
Try this template instead. I think you will find it takes at most a few seconds on the full library.
Code:
python:
def evaluate(book, context):
db = context.db.new_api
authors_with_notes = context.globals.get('authors_with_notes')
if authors_with_notes is None:
print('authors notes is none')
authors_with_notes = db.get_all_items_that_have_notes('authors')
context.globals['authors_with_notes'] = authors_with_notes
context.globals['item_name_map'] = db.get_item_name_map('authors')
item_name_map = context.globals['item_name_map']
for aut in book.authors:
if item_name_map.get(aut) in authors_with_notes:
return '1'
return ''