View Single Post
Old 10-25-2024, 02:10 PM   #744
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,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Wiggo View Post
I have a column #series authors (thx chaley)

Spoiler:
Code:
python:
def evaluate(book, context):
    if book.series is None:
        return ''
    db = context.db.new_api
    ans = set()
    # Get the list of books in the series
    ids = db.search(f'series:"={book.series}"', '')
    if ids:
        # Get all the author_sort values for the books in the series
        author_sorts = (v for v in db.all_field_for('author_sort', ids).values())
        # Add the names to the result set, removing duplicates
        for aus in author_sorts:
            ans.update(v.strip() for v in aus.split('&'))
    # Make a sorted comma-separated string from the result set
    return ', '.join(v.replace(',', ';') for v in sorted(ans))


And I have a column symbol for more than one series author
Code:
program:
	if list_count($#series_authors, ',') > 1 then
		'series_authors.png'
	fi
I wanted to replace list_count by list_count_field but I get an error
Code:
program:
	if list_count_field('#series_authors') > 1 then
		'series_authors.png'
	fi
Attachment 211650

I installed Calibre 7.20.100 but as always, I have no idea.
Composite columns are strings, not multi-valued lists. list_count_field() would be slower than list_count(), so the it doesn't try. Doing further error checking would slow it down even more.
chaley is offline   Reply With Quote