|
|
#1 |
|
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 168
Karma: 31650
Join Date: May 2011
Location: Asuncion (Paraguay)
Device: In the house, 3 K3 in use, 4 more in storage, and a K5 for testing
|
Selecting the highest Series_Index ?
I am trying to update my library, to check that I have the latest(s) book(s) in each of the Series I have been reading.
Is there a way, for all the Series in a library, to selet only the books with the highest Series_Index of each Series ? |
|
|
|
|
|
#2 |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 80,817
Karma: 150249619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Sort by series and then you can scroll to see which books are the highest number easily.
|
|
|
|
| Advert | |
|
|
|
|
#3 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
template:"""program:
vals = globals(vals='');
if !vals then
all_series = book_values('series', 'series:true', ',', 0);
for series in all_series:
indices = book_values('series_index', 'series:="' & series & '"', ',', 0);
first = 1;
highest = 0;
for index in indices:
if first || index ># highest then highest = index; first = '' fi
rof;
vals = list_union(vals, series & ':' & highest, ',')
rof;
set_globals(vals)
fi;
if $series && $series_index ==# select(vals, $series) then '1' fi#@#:n:1"""
Code:
program:
vals = globals(vals='');
if !vals then
all_series = book_values('series', 'series:true', ',', 0);
for series in all_series:
indices = book_values('series_index', 'series:="' & series & '"', ',', 0);
first = 1;
highest = 0;
for index in indices:
if first || index ># highest then highest = index; first = '' fi
rof;
vals = list_union(vals, series & ':' & highest, ',')
rof;
set_globals(vals)
fi;
if $series && $series_index ==# select(vals, $series) then '1' fi
|
|
|
|
|
|
|
#4 |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,271
Karma: 61916422
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
The Quality check plugin looks for Gaps (thus it must find the highest
present)
|
|
|
|
|
|
#5 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,216
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
Since this is an old thread that predates the introduction of python templates by chaley, here is the python equivalent for the chaley's GPM template:
Code:
python:
def evaluate(book, context):
vals = context.globals.get('highest_index_ids')
if not vals:
vals = context.globals['highest_index_ids'] = []
db = context.db
cats = db.new_api.get_categories(book_ids=None)
all_series = [ t.name for t in cats['series'] ]
for series in all_series:
book_ids = db.data.search_getting_ids(f'series:"={series}"', '')
indices = {}
for book_id in book_ids:
idx = db.new_api.field_for('series_index', book_id)
indices[idx] = book_id
vals.append(indices[max(indices.keys())])
return '1' if book.id in vals else '0'
Last edited by capink; 04-24-2023 at 05:27 PM. |
|
|
|
| Advert | |
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Why series_index is double and not int? | Angelo.Mascaro | Development | 11 | 10-22-2019 07:00 AM |
| Series_Index search | Sami | Library Management | 7 | 09-25-2015 11:54 AM |
| Plugboard, template series_index first? | Truthowl | Library Management | 6 | 09-13-2014 01:34 PM |
| series_index manipulation | kcz | Library Management | 15 | 10-15-2013 10:26 AM |
| Customize series_index value | luoman | Calibre | 3 | 08-23-2013 05:11 AM |