View Single Post
Old 12-16-2023, 07:14 PM   #8
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,509
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Comfy.n View Post
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 ''
chaley is offline   Reply With Quote