Repository navigation
Conversation
The catalog and Books List can store a Calibre rating and numeric custom columns, but could not order the whole library by those values. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CWA stores a standard Calibre rating and numeric custom columns, but the cover catalog and the Books List cannot order the whole library by those values. A rating can be used to group books, and the table headers for
intandfloatcustom columns are not sortable.Solution
Add one server-side sort for the Calibre rating and for every custom column of datatype
intorfloat. The order is applied to the existing paged queries, before pagination, as a correlated scalar subquery. That keeps the current joins from duplicating rows. Column ids are checked against the library metadata and are never interpolated into SQL.Features
#goodreads_ratingappears automatically. A column of another datatype does not.intandfloatcustom columns.0means unrated.0in a custom column is a real value.Testing
tests/unit/test_rating_sort.py(73 tests): both directions for the rating and forint/floatcolumns, missing values last,0in a custom column kept in order, an empty column keeping title order, several columns, a library with no custom columns, paging of the whole library, a filter plus paging, the series join used by the book lists, stable order when only the first sort expression is applied, ignored and read-only columns, invalid keys including SQL fragments, andlist_booksforratingsandcustom_column_<id>pytest -m "smoke or unit"locally: 347 passed, 24 skipped