Skip to content

Group library series and authors whose names differ only in punctuation - #91

Open
TheMightyTRex wants to merge 1 commit into
logabell:mainfrom
TheMightyTRex:contrib/series-name-grouping
Open

TheMightyTRex wants to merge 1 commit into
logabell:mainfrom
TheMightyTRex:contrib/series-name-grouping

Conversation

@TheMightyTRex

Copy link
Copy Markdown

Problem

My Library's Series and Authors tabs group books by the name in lower case with spaces collapsed. When the same series or author is spelt slightly differently by different sources, the library shows separate cards for what is one series or one person. For example:

  • "Discworld: Industrial Revolution" and "Discworld - Industrial Revolution"
  • "The Silver Ships" and "Silver Ships"
  • "Dan Deadman Space Detective" and "Dan Deadman Space Detective Series"
  • "J.R.R. Tolkien" and "J. R. R. Tolkien"

Change

services/app/api/library_groups.py:

  • Groups now use a key that ignores case and punctuation and reads "&" as "and". For series, the key also drops a leading "The" and a trailing "Series".
  • Opening a group (/api/library/groups/{kind}/books?name=..., which the web app calls with the group URL parameter) builds the same key from the name it receives, so a merged card lists the books from every spelling, whichever spelling is passed.
  • Search still matches the names as written. A group is kept when any of its spellings matches, and it keeps its full book count.

The card shows one of the spellings as its name, as before. The web app needs no change: it passes the card's name back to open the group, and uses key only to tell cards apart.

Testing

  • New integration test in tests/integration/test_library_groups.py covering the series cases above, an author spelt two ways, search by one spelling, and opening a merged group by either spelling.
  • tests/integration/test_library_groups.py and tests/integration/test_library_projection_scaling.py: 13 passed.
  • ruff check and ruff format --check pass.

🤖 Generated with Claude Code

My Library's Series and Authors tabs grouped by the lowercased name with
spaces collapsed, so "Discworld: Industrial Revolution" and "Discworld -
Industrial Revolution" became two cards, as did "The Silver Ships" and
"Silver Ships", or "J.R.R. Tolkien" and "J. R. R. Tolkien".

Groups now share a key that ignores case and punctuation (and treats "&"
as "and"); series also ignore a leading "The" and a trailing "Series".
Opening a group computes the same key from the name it was given, so a
merged card lists the books from every spelling. Search still matches the
names as written, and a matching group keeps its full book count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant