![]() |
#1 |
want to learn what I want
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 Code:
program: book_count('publisher',0); 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 |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 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. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
want to learn what I want
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
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 |