feat: narrow manual title lookup by author #86

Merged
jfro merged 2 commits from feat/title-author-lookup into main 2026-10-25 22:15:05 +00:00
Owner

Closes #77

What changed

  • Title Search tab on Add Book has an optional Author field. After a lookup the form keeps title and author so you can refine.
  • BookLookupProvider gets an optional lookup_by_title_and_author/2 callback. BookLookup.lookup_by_title/2 uses it where a provider has it, otherwise falls back to title search. Either way, results whose author matches (every word, ignoring case/accents/punctuation/order, e.g. "tolkien" ↔ "J. R. R. Tolkien", "Herbert, Frank" ↔ "Frank Herbert") are ranked first. Blank author = the old title search.
  • Providers:
    • Open Library: search.json?title=…&author=… (both properly query-encoded)
    • Google Books: q=intitle:… inauthor:…
    • Library of Congress: bath.title="…" and bath.author="…" (checked live against lx2.loc.gov)
    • Hardcover: author added to the search query text (its book search matches author_names). Nye is researching Hardcover; will adjust if there's a better field-scoped way.
  • Logger line per title+author lookup: provider, result count, how many match the author, whether the author was in the query, duration. Open Library logs non-200 statuses now too. Open Library gets an :open_library_req_options hook (like Google's) for tests.

Tested

  • book_lookup_author_test.exs: author passed to capable providers, fallback + ranking for title-only ones, unconfigured providers skipped, blank/nil author is a plain title search, author matching rules.
  • Open Library + Google Books request tests (Req.Test) check the query params sent.
  • Controller test: author field on the page, posted author reaches the provider, title/author refilled.
  • Live in dev (Open Library): "Dune" + "Brian Herbert" → 10 results, all matching author.
  • mix precommit passes (647 tests).

Not tried live: Hardcover (no API token on my dev box), Google Books (quota exhausted today; covered by the stubbed test).

Closes #77 **What changed** - Title Search tab on Add Book has an optional **Author** field. After a lookup the form keeps title and author so you can refine. - `BookLookupProvider` gets an optional `lookup_by_title_and_author/2` callback. `BookLookup.lookup_by_title/2` uses it where a provider has it, otherwise falls back to title search. Either way, results whose author matches (every word, ignoring case/accents/punctuation/order, e.g. "tolkien" ↔ "J. R. R. Tolkien", "Herbert, Frank" ↔ "Frank Herbert") are ranked first. Blank author = the old title search. - Providers: - Open Library: `search.json?title=…&author=…` (both properly query-encoded) - Google Books: `q=intitle:… inauthor:…` - Library of Congress: `bath.title="…" and bath.author="…"` (checked live against lx2.loc.gov) - Hardcover: author added to the search query text (its book search matches `author_names`). Nye is researching Hardcover; will adjust if there's a better field-scoped way. - Logger line per title+author lookup: provider, result count, how many match the author, whether the author was in the query, duration. Open Library logs non-200 statuses now too. Open Library gets an `:open_library_req_options` hook (like Google's) for tests. **Tested** - `book_lookup_author_test.exs`: author passed to capable providers, fallback + ranking for title-only ones, unconfigured providers skipped, blank/nil author is a plain title search, author matching rules. - Open Library + Google Books request tests (Req.Test) check the query params sent. - Controller test: author field on the page, posted author reaches the provider, title/author refilled. - Live in dev (Open Library): "Dune" + "Brian Herbert" → 10 results, all matching author. - `mix precommit` passes (647 tests). Not tried live: Hardcover (no API token on my dev box), Google Books (quota exhausted today; covered by the stubbed test).
jfro added this to the v0.9.0 milestone 2026-10-25 21:02:54 +00:00
feat: narrow manual title lookup by author
All checks were successful
CI / test (pull_request) Successful in 47s
db5d0864c9
The Title Search tab gets an optional Author field. Open Library, Google
Books, Library of Congress and Hardcover search by title and author
together (new optional lookup_by_title_and_author/2 callback); for any
provider without it BookLookup searches by title. Either way results whose
author matches come first. The form keeps the title and author after a
lookup so the search can be refined.

Closes #77
fix: keep & intact in title-only provider searches
All checks were successful
CI / test (pull_request) Successful in 47s
31347dd6e6
Open Library, Google Books and Library of Congress built title-only
search URLs with URI.encode/1, which leaves & unescaped, so a title like
"Pride & Prejudice" was split into a broken query.
jfro merged commit c4e18ba0a8 into main 2026-10-25 22:15:05 +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!86
No description provided.