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 09-21-2024, 09:39 PM   #721
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,018
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
list_filter() would definitely be more intuitive and ist_add() also being faster would be an advantage.
ownedbycats is online now   Reply With Quote
Old 10-12-2024, 04:43 PM   #722
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,018
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Arithmetic - how do I apply a format to the results?

e.g. program: divide($$#purchasecost, 1.15) returns 7.9913043478260875 when I just need 7.99. ({0:,.2f})

Last edited by ownedbycats; 10-12-2024 at 05:44 PM.
ownedbycats is online now   Reply With Quote
Old 10-12-2024, 05:56 PM   #723
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Arithmetic - how do I apply a format to the results?

e.g. program: divide($$#purchasecost, 1.15) returns 7.9913043478260875 when I just need 7.99. ({0:,.2f})
Use format_number(x, '.2f') or perhaps finish_formatting() if you want a prefix and/or a suffix.

Also, $$#purchasecost/1.15 is faster than using the divide() function.
chaley is offline   Reply With Quote
Old 10-17-2024, 12:07 AM   #724
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,018
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Another question: After deleting an integer column (was converting it to a composite), I noticed that a template that checked the integer still worked, but treated everything as a '0'. Is this intentional?

Last edited by ownedbycats; 10-17-2024 at 12:09 AM.
ownedbycats is online now   Reply With Quote
Old 10-18-2024, 05:38 PM   #725
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Another question: After deleting an integer column (was converting it to a composite), I noticed that a template that checked the integer still worked, but treated everything as a '0'. Is this intentional?
Yes, assuming you are using raw_field() or $$ to fetch the value. It returns None for columns that don't exist. None is interpreted as zero in an arithmetic context. Using field() or $ will throw an error
chaley is offline   Reply With Quote
Old 10-20-2024, 10:07 PM   #726
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,018
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
A composite column #timesread calls field_list_count().

A second composite column then uses $$#timesread (previously it was integer column) as a check. Would using field_list_count() directly in that composite increase performance?

Last edited by ownedbycats; 10-20-2024 at 10:10 PM.
ownedbycats is online now   Reply With Quote
Old 10-21-2024, 01:42 AM   #727
correoparaappzz
Connoisseur
correoparaappzz began at the beginning.
 
Posts: 66
Karma: 10
Join Date: Nov 2023
Device: Kindle Oasis
exclude books with specific tag

Code:
elif $series == "" && $#audiobook != ""
	then "Stand-Alone with AB"
what can i add to exclude books with the tag #Collection/Box Set?

correoparaappzz is offline   Reply With Quote
Old 10-21-2024, 01:49 AM   #728
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,018
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by correoparaappzz View Post
Code:
elif $series == "" && $#audiobook != ""
	then "Stand-Alone with AB"
what can i add to exclude books with the tag #Collection/Box Set?

try

Code:
	elif 
		$series == "" 
		&& $#audiobook != "" 
		&& !"#Collection/Box Set" inlist $tags
	then 
		"Stand-Alone with AB"
ownedbycats is online now   Reply With Quote
Old 10-21-2024, 02:01 AM   #729
correoparaappzz
Connoisseur
correoparaappzz began at the beginning.
 
Posts: 66
Karma: 10
Join Date: Nov 2023
Device: Kindle Oasis
Quote:
Originally Posted by ownedbycats View Post
try

Code:
	elif 
		$series == "" 
		&& $#audiobook != "" 
		&& !"#Collection/Box Set" inlist $tags
	then 
		"Stand-Alone with AB"
works perfectly,
correoparaappzz is offline   Reply With Quote
Old 10-21-2024, 02:14 AM   #730
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,018
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
you should also be able to replace $#audiobook != "" with just !$#audiobook
ownedbycats is online now   Reply With Quote
Old 10-21-2024, 06:29 AM   #731
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
A composite column #timesread calls field_list_count().

A second composite column then uses $$#timesread (previously it was integer column) as a check. Would using field_list_count() directly in that composite increase performance?
I'm not sure what you are asking.

If you are asking if it would be faster to use field_list_count() instead of $$#timesread then the answer is yes. In the best case where $$#timesread has already been evaluated for the book then the performance improvement will be around 2 times. If $$#timesread hasn't yet been evaluated for the book then the performance improvement is at least 10 times.

If you are using $#timesread (not raw_field()) then the performance improvement of using field_list_count() directly is probably 10 to 100 times.

Last edited by chaley; 10-21-2024 at 06:55 AM. Reason: corrected spelling error
chaley is offline   Reply With Quote
Old 10-21-2024, 09:14 AM   #732
1ily
Connoisseur
1ily doesn't litter1ily doesn't litter
 
Posts: 63
Karma: 190
Join Date: Sep 2023
Device: Kobo Libra 2
Hello! I'm using a template that uses the word count column to assign a book's tags.

I have tags for Comics, Novellas, Novels, and Long. Ideally, anything under 2k words will be a Comic, under 40k is a Novella, 150k is a Novel, and anything above that is Long.

It turns out that books with 100k and higher have the "Novel"/"Long" and the "comic" tags, books with 50k-100k words have the correct tags. Books less than 1k are not being given the "comic" tag and books over 188k are not being given any tags at all.

What am I doing wrong?


Example:

Code:
program:	

words = $$#words;
pages = $$#pages;

new_colls = strcat(
if (words < 1500000 && words > 150000) then 'Long,' fi,
if (words < 150000 && words > 50000) then 'Novel,' fi,
if (words < 40000 && words > 2000) then 'Novella,' fi,
if (words < 2000 && words > 0 && pages > 0) then 'Comic,' fi
)

new_colls
1ily is offline   Reply With Quote
Old 10-21-2024, 09:33 AM   #733
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by 1ily View Post
Hello! I'm using a template that uses the word count column to assign a book's tags.

I have tags for Comics, Novellas, Novels, and Long. Ideally, anything under 2k words will be a Comic, under 40k is a Novella, 150k is a Novel, and anything above that is Long.

It turns out that books with 100k and higher have the "Novel"/"Long" and the "comic" tags, books with 50k-100k words have the correct tags. Books less than 1k are not being given the "comic" tag and books over 188k are not being given any tags at all.

What am I doing wrong?


Example:

Code:
program:	

words = $$#words;
pages = $$#pages;

new_colls = strcat(
if (words < 1500000 && words > 150000) then 'Long,' fi,
if (words < 150000 && words > 50000) then 'Novel,' fi,
if (words < 40000 && words > 2000) then 'Novella,' fi,
if (words < 2000 && words > 0 && pages > 0) then 'Comic,' fi
)

new_colls
You are using the string (lexical) comparison operator (<) instead of the numeric comparison operator (<#).

As said in the template language manual, which is your friend:
Quote:
Relational operators

Relational operators return '1' if the comparison is true, otherwise the empty string (‘’).

There are two forms of relational operators: string comparisons and numeric comparisons.

String comparisons do case-insensitive string comparison using lexical order. The supported string comparison operators are ==, !=, <, <=, >, >=, in, and inlist. For the in operator, the result of the left hand expression is interpreted as a regular expression pattern. The in operator is True if the value of left-hand regular expression matches the value of the right hand expression. The inlist operator is true if the left hand regular expression matches any one of the items in the right hand list where the items in the list are separated by commas. The matches are case-insensitive.

The numeric comparison operators are ==#, !=#, <#, <=#, >#, >=#. The left and right expressions must evaluate to numeric values with two exceptions: both the string value “None” (undefined field) and the empty string evaluate to the value zero.
BTW: the first_matching_cmp() or the switch_if() functions seem to satisfy your needs and are faster than a series of if statements.

BTW2: it seems you should be using >=# in the second relational clause of the if statements. Otherwise you are skipping exact matches.

Last edited by chaley; 10-21-2024 at 09:37 AM. Reason: Added BTW2
chaley is offline   Reply With Quote
Old 10-21-2024, 09:50 AM   #734
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,018
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by chaley View Post
I'm not sure what you are asking.

If you are asking if it would be faster to use field_list_count() instead of $$#timesread then the answer is yes. In the best case where $$#timesread has already been evaluated for the book then the performance improvement will be around 2 times. If $$#timesread hasn't yet been evaluated for the book then the performance improvement is at least 10 times.

If you are using $#timesread (not raw_field()) then the performance improvement of using field_list_count() directly is probably 10 to 100 times.
Yes, specifically line three here:

Code:
program:
	status = readstatus();
	times = field_list_count('#datesread');
	readgoal = strcat('readinggoal:', format_date(today(), 'yyyy')) in $#admintags;

	switch_if(
		status=='read', 'Read',
		status=='didnotfinish', 'Did Not Finish',
		status=='currentlyreading', 
			if times >#0 then 'Currently Rereading' 
			else 'Currently Reading' fi,
		status=='toberead', 'To Be Read',
		status=='unread', 
			if readgoal && $$#lastread != 'None' then 'To Be Read' 
			elif readgoal then 'Backlog' 
			else 'Unread' fi,
		''
	)
When #timesread column used to be an integer, I used that for 'times.' Now that it's a composite, I switched to using field_list_count() directly.

I just realized I could probably speed up this template a nudge by turning those nested if-thens into switch_ifs.
ownedbycats is online now   Reply With Quote
Old 10-21-2024, 02:48 PM   #735
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,018
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program:

	readgoal = strcat('readinggoal:', format_date(today(), 'yyyy'));
	challenge =	strcat('rgchallenges:purchases', format_date(today(), 'yyyy'));

	if
		format_date($date, 'yyyy') == format_date(today(), 'yyyy')
		&& readgoal in $#admintags
		&& $#purchasesource
		&& $#cost !='0.00'

	then
		list_union(challenge, $#admintags, ',')
	else
		$#admintags
	fi
Line 7 I'm trying to check whether the book's timestamp/date is set to this year. Is this the best method to do so?

Last edited by ownedbycats; 10-21-2024 at 05:10 PM.
ownedbycats is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Library Management: various questions not worth their own thread ownedbycats Library Management 218 07-11-2025 07:34 PM
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates Boilerplate4U Development 13 07-07-2020 02:35 AM
Questions on Kobo [Interfered with another thread topic] spdavies Kobo Reader 8 10-12-2014 11:37 AM
[OLD Thread] Some questions before buying the fire. darthreader13 Kindle Fire 7 05-10-2013 09:19 PM
Thread management questions meme Feedback 6 01-31-2011 05:07 PM


All times are GMT -4. The time now is 03:43 AM.


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