Thread: Publisher count
View Single Post
Old 11-14-2024, 08:54 AM   #2
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
The correct query is
Code:
program: book_count('publisher:=' & $publisher & '"', 0)
This template could be too slow to use in a composite column. You can use it in action chains to set the count.

This python template should be fast enough to use directly in a composite
Code:
python:
def evaluate(book, context):
	db = context.db.new_api
	pub_id = db.field_ids_for('publisher', book.id)
	if not pub_id:
		return '0'
	pub_id = pub_id[0]
	counts = db.get_usage_count_by_id('publisher')
	return str(counts[pub_id])

Last edited by chaley; 11-14-2024 at 08:59 AM.
chaley is offline   Reply With Quote