Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 11-14-2024, 05:22 AM   #1
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,611
Karma: 7891011
Join Date: Sep 2020
Device: none
Publisher count

Hi chaley,

This is mostly out of curiosity as I'm exploring the Template functions.

I'm using the plugin Author Book Count to populate a column that stores the total number of books by each author while also providing an optional integer column that supports arithmetic search queries, named abc_numeric (I have a grouped search using 'abc' as lookup alias instead). So I sometimes do searches like

Code:
not abc:=1
Now I was thinking of creating a similar column for Publisher and I found that using...

Code:
program: book_count('publisher',0);
...doesn't work, so my query is incorrect.

Would you please advise a good way to create such a column?

(I have already set the tweak allow_template_database_functions_in_composites to True.)

Last edited by Comfy.n; 11-14-2024 at 06:27 AM. Reason: removed the # symbol
Comfy.n is offline   Reply With Quote
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,443
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
Advert
Old 11-14-2024, 09:31 AM   #3
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,611
Karma: 7891011
Join Date: Sep 2020
Device: none
The python template is fast enough, thank you! I think I'm going to keep it for a while to see how it goes.
Comfy.n is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add page count, word count and reading time ZodWallop Kobo Reader 4 08-12-2024 05:56 AM
Word Count and Page Count? CrossReach Library Management 2 07-19-2018 05:44 PM
Count yourself in wannabee Lounge 24 12-13-2011 08:54 AM
Count Me In Teleguy1955 Ectaco jetBook 6 11-04-2010 03:27 PM
Too many to count....... Stonecoldcrb Sony Reader 16 07-16-2007 03:45 PM


All times are GMT -4. The time now is 12:41 PM.


MobileRead.com is a privately owned, operated and funded community.