View Single Post
Old 12-19-2023, 08:44 AM   #10
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,529
Karma: 8075938
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Here is a template that you can customize to check columns other than authors. Change 'authors' in the line "column = 'authors'" to the lookup name of your choice.

Code:
python:
def evaluate(book, context):
	column = 'authors'

	db = context.db.new_api
	items_with_notes = context.globals.get('items_with_notes')
	if items_with_notes is None:
		items_with_notes = db.get_all_items_that_have_notes(column)
		context.globals['items_with_notes'] = items_with_notes
		context.globals['item_name_map'] = db.get_item_name_map(column)
	item_name_map = context.globals['item_name_map']

	vals = book.get(column)
	if vals is None:
		return ''
	if isinstance(vals, str):
		vals = tuple((vals,))
	for val in vals:
		if item_name_map.get(val) in items_with_notes:
			return '1'
	return ''

Last edited by chaley; 12-19-2023 at 08:49 AM.
chaley is offline   Reply With Quote