![]() |
#1 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,973
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Finding partially read series
Using either the built-in search functions or a plugin (MCS?), is there a way to find series that have nonidentical metadata in a specific column?
I have a composite #readstatus column. I want to find series where all the books aren't either 'Read' or 'Unread.' Thanks ![]() |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
You don't say if #readstatus can have values other than 'Read' or 'Unread'. I assume it can't. The templates below won't work if my assumption is wrong.
These two templates return 'Yes' if #readstatus has more than one value for a series, the empty string otherwise. The GPM template is probably easier for you to maintain. The Python template is much faster. Edit: add comments to the template, and remove the trailing comma Code:
program: globals(answers = ''); if !answers then # Get a list of series names series_names = book_values('series', 'id:true', ',', 1); # Loop over the series names for series in series_names: # Get all the values in the '#readstatus column values = book_values('#readstatus', 'series:="' & series & '"', ',', 1); if list_count(values, ',') > 1 then # More than one value found. Store the series in the answers global for later use answers = answers & series & ',' fi rof; # remove the trailing comma answers = re(answers, ',$', ''); set_globals(answers) fi; str_in_list(answers, ',', $series, 'Yes', '') Code:
python: def evaluate(book, context): db = context.db.new_api answer = context.globals.get('answer', None) if answer is None: answer = set() all_series = db.all_field_names('series') for series in all_series: series_id = db.get_item_id('series', series) books_in_series = db.books_for_field('series', series_id) vals = db.all_field_for('#readstatus', books_in_series) unique_vals = {v for v in vals.values()} if len(unique_vals) > 1: answer.add(series) context.globals['answer'] = answer return 'Yes' if book.series in answer else '' Last edited by chaley; 03-09-2023 at 08:38 AM. Reason: add comments to the template, and remove the trailing comma |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,973
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
It does have other statuses; read, unread, currently reading, to be read, and undefined.
|
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,628
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
So, I'm assuming this template would give you all the unfinished series.... I would like to use them in a search, not adding a composite column. How could I do that? Sorry, my searches are quite simple... and this can avoid me a function I've not that calculates some data for a series every time I add or read a book.
|
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
You get to Template Search using the advanced search button. Using the above python template as an example, the template search would be: |
|
![]() |
![]() |
![]() |
#7 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,973
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
It pulls from my readstatus() template:
Code:
program: if $$#percentread >=#1 && $$#percentread <=#99 then 'currentlyreading' elif "To Be Read" in $#readinglist && $$#percentread ==#0 then 'toberead' elif $$#percentread >=#100 then 'read' elif $$#percentread == 'None' then 'undefined' elif $$#percentread >=#0 then 'unread' fi Code:
program: if readstatus()=='currentlyreading' then 'Currently Reading' elif readstatus()=='toberead' then 'To Be Read' elif readstatus()=='read' then 'Read' elif readstatus()=='unread' then 'Unread' elif readstatus()=='Undefined' then 'Undefined' fi For example, a series of three books: All three books are 'unread' - false The first two books are 'read', and the third 'unread' - true The first book is 'read', the second is 'to be read', and the third 'unread' - true Last edited by ownedbycats; 03-09-2023 at 08:19 AM. |
![]() |
![]() |
![]() |
#8 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
The above templates do that. They return 'Yes' when the list of values for books in a series contains one result. It doesn't matter what that result is, only that there is only one. For example, it will return 'Yes' when one book has 'Undefined' and another book has 'Unread'. If all books have the same value such as 'toberead' then the template returns ''.
|
![]() |
![]() |
![]() |
#9 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,628
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#10 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,973
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
It works
![]() ![]() |
![]() |
![]() |
![]() |
#11 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,628
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Thank you! It works perfectly with my column for reading status.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Finding Series of Capitalized Words? | enuddleyarbl | ePub | 5 | 02-12-2023 12:18 PM |
Amazon partially fixed bug that did not read metadata | darrenma | Amazon Kindle | 5 | 10-27-2022 03:08 AM |
Finding What Books are Missing from a series | Spuggyface | Reading and Management | 3 | 02-08-2017 08:06 PM |
Need help finding a certain type of series - Help please! | damican | Reading Recommendations | 31 | 02-21-2015 08:02 PM |
Need help finding something new to read. | darearkin | Reading Recommendations | 24 | 01-27-2012 09:58 AM |