feat: keep each author of a book and link them separately #96

Merged
jfro merged 3 commits from feat/multiple-authors into main 2026-10-25 23:36:50 +00:00
Owner

Closes #82. Based on main; follows Nye's research notes (keep the byline, add a list, no join table).

Schema: author stays the byline (sort, search, matching, CSV and required validation untouched). New authors {:array, :string}, default [], not null, GIN index. Migration 20261026010000 (after #88's) backfills existing rows in batches of 500 with the same pure splitter; tested up, down, up.

Changeset: a provider's authors list wins; otherwise authors follows the byline whenever it changes; a list with no byline becomes the byline (", "-joined). Blanks, "Unknown Author" and case-duplicates dropped.

Splitter FuzzyCatalog.Catalog.AuthorNames (pure): splits on , & ; and; flips Last, First (Pratchett, Terry, Herbert, Frank, Anderson, Kevin J.), but not AC/DC, Neil Gaiman; keeps Jr. and initials. Known weak spot (as Nye noted): Le Guin, Ursula K. typed in by hand splits in two; provider lists avoid it. BookMatcher.author_names/1 (matching) left as is.

Providers: Open Library (search), Google Books, Hardcover (search + ISBN; ISBN keeps only contributions nil/"Author", so translators/illustrators drop out) return authors:. Library of Congress builds one name per <mods:name> as "First Last" (inverted namePart or family+given, dates and trailing punctuation dropped), so its byline is now "Neil Gaiman, Terry Pratchett" instead of "Gaiman, Neil., Pratchett, Terry.". BookLookup fills authors by splitting for any provider that doesn't send one. Lookup results carry the list to Add to Library as book[authors][].

Links: new <.author_links> on the book page and both library views, one link per author (old rows fall back to splitting the byline). get_books_by_author/1 matches name = ANY(authors) or the byline. Links now use ~p encoding only (/author/Neil%20Gaiman, was double-encoded %2520); a name with / works (tested).

Tests: author_names_test.exs, book_authors_test.exs (changeset, list vs byline, edit, author_list fallback, get_books_by_author incl. un-backfilled row, LoC MODS fixture), book_authors_controller_test.exs (book page, library list, author page, AC/DC link round trip, add-from-lookup keeps list). mix precommit: 650 tests pass.
Browser check: dev DB backfill split "Terry Pratchett, Neil Gaiman", "Pratchett, Terry", "Brian Herbert & Kevin J. Anderson" correctly; Good Omens page shows two author links and each author page lists it (Terry Pratchett's also lists Mort).

Merging: textually clean against #86–#90 and #94. #89 (refresh metadata): picking a provider's author re-derives the list from the byline via the changeset; carrying the provider list through is a small follow-up after both merge.

Closes #82. Based on main; follows Nye's research notes (keep the byline, add a list, no join table). **Schema:** `author` stays the byline (sort, search, matching, CSV and required validation untouched). New `authors {:array, :string}`, default `[]`, not null, GIN index. Migration `20261026010000` (after #88's) backfills existing rows in batches of 500 with the same pure splitter; tested up, down, up. **Changeset:** a provider's `authors` list wins; otherwise `authors` follows the byline whenever it changes; a list with no byline becomes the byline (`", "`-joined). Blanks, "Unknown Author" and case-duplicates dropped. **Splitter** `FuzzyCatalog.Catalog.AuthorNames` (pure): splits on `,` `&` `;` `and`; flips `Last, First` (`Pratchett, Terry`, `Herbert, Frank, Anderson, Kevin J.`), but not `AC/DC, Neil Gaiman`; keeps `Jr.` and initials. Known weak spot (as Nye noted): `Le Guin, Ursula K.` typed in by hand splits in two; provider lists avoid it. `BookMatcher.author_names/1` (matching) left as is. **Providers:** Open Library (search), Google Books, Hardcover (search + ISBN; ISBN keeps only contributions nil/"Author", so translators/illustrators drop out) return `authors:`. Library of Congress builds one name per `<mods:name>` as "First Last" (inverted namePart or family+given, dates and trailing punctuation dropped), so its byline is now "Neil Gaiman, Terry Pratchett" instead of "Gaiman, Neil., Pratchett, Terry.". `BookLookup` fills `authors` by splitting for any provider that doesn't send one. Lookup results carry the list to Add to Library as `book[authors][]`. **Links:** new `<.author_links>` on the book page and both library views, one link per author (old rows fall back to splitting the byline). `get_books_by_author/1` matches `name = ANY(authors)` or the byline. Links now use `~p` encoding only (`/author/Neil%20Gaiman`, was double-encoded `%2520`); a name with `/` works (tested). **Tests:** `author_names_test.exs`, `book_authors_test.exs` (changeset, list vs byline, edit, author_list fallback, get_books_by_author incl. un-backfilled row, LoC MODS fixture), `book_authors_controller_test.exs` (book page, library list, author page, AC/DC link round trip, add-from-lookup keeps list). `mix precommit`: 650 tests pass. **Browser check:** dev DB backfill split "Terry Pratchett, Neil Gaiman", "Pratchett, Terry", "Brian Herbert & Kevin J. Anderson" correctly; Good Omens page shows two author links and each author page lists it (Terry Pratchett's also lists Mort). **Merging:** textually clean against #86–#90 and #94. #89 (refresh metadata): picking a provider's author re-derives the list from the byline via the changeset; carrying the provider list through is a small follow-up after both merge.
jfro added this to the v0.9.0 milestone 2026-10-25 22:09:20 +00:00
feat: keep each author of a book and link them separately
All checks were successful
CI / test (pull_request) Successful in 47s
9f30f48a03
Books keep `author` as the byline and gain `authors`, one entry per
person (migration adds the column with a GIN index and backfills it
from existing bylines). Lookup providers pass their author lists
through; Library of Congress names are turned into "First Last".
Bylines typed in or imported are split on commas, &, ; and "and",
with "Last, First" flipped. The book page and library list link each
author on their own, and an author's page finds books listing them
among others.

Closes #82
fix: flip multi-word surnames in Last, First bylines
All checks were successful
CI / test (pull_request) Successful in 49s
01f46b86d8
"Le Guin, Ursula K." (as the old Library of Congress provider stored
names) split into two authors. Allow surnames of up to three words when
the other part is a first name, and drop catalog life dates like
"1929-2018". Found by Nye (F4).
Merge remote-tracking branch 'origin/main' into feat/multiple-authors
All checks were successful
CI / test (pull_request) Successful in 1m7s
96c26fdb5e
# Conflicts:
#	lib/fuzzy_catalog_web/controllers/book_html.ex
jfro merged commit efb1cd5434 into main 2026-10-25 23:36:50 +00:00
jfro deleted branch feat/multiple-authors 2026-10-25 23:36:50 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/fuzzy_catalog!96
No description provided.