From chaley is this template which can be used to search for series with more than one book:
Quote:
Originally Posted by chaley
This template search should be fast enough to use in a VL. You probably want to make it a stored template.
Code:
python:
def evaluate(book, context):
# Return True ('yes') if the value in 'field' is used by more than 'test_count' books.
# This template only works with single value fields such as Series, Publisher, and enumerations
field = 'series'
test_count = 1
db = context.db.new_api
id_map = context.globals.get('id_map')
if id_map is None:
context.globals['id_map'] = id_map = db.get_item_name_map(field)
context.globals['item_book_count'] = db.get_usage_count_by_id(field)
item_book_count = context.globals['item_book_count']
item_id = id_map.get(book.get(field))
if item_id is None or item_book_count.get(item_id, 0) <= test_count:
return ''
return 'yes'
|