openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

"Continue Reading" Phase 1: Merge Active Loans & Loan History Carousel

Open Sadashii opened this issue 3 months ago • 1 comments

Epic: #13256 — "Continue Reading" Flow & Auto-Add Prompts (open) This is Phase 1 of that epic. Check the epic issue for overall status and the dependency graph.


Feature Request

Problem / Opportunity

New patrons land on an empty My Books page — the Loans carousel just says "No books are on this shelf," with no path back to value. Most CDL loans are ~1hr; once expired, they vanish from the active dashboard with no "pick up where you left off" surface. Patrons who borrowed a book yesterday return to an empty dashboard with nothing to engage with.

The measurable impact is patron retention: populated shelves correlate strongly with retention, and today we have no mechanism to preserve short-term borrow history on the dashboard.

Success: After this ships, a patron who borrowed any book in the past will see it in their "My Loans" carousel even after the loan has expired, providing an immediate "continue reading" path.

Proposal

Replace the legacy active-only Loans carousel on the My Books page with a unified carousel that merges:

  1. Active CDL loans (books currently checked out).
  2. Past loan history (returned/expired borrows, sourced from user_borrow_history).

Books will be deduplicated by OLID (active loan takes priority) and sorted by last-access timestamp descending.

This is Phase 1 of Epic #13256.


Breakdown

Implementation Details (for maintainers)

Related files

Refer to this map of common Endpoints:

  • openlibrary/plugins/upstream/mybooks.py — loans data marshalling and carousel data assembly
  • openlibrary/templates/account/mybooks.html — carousel template rendering
  • openlibrary/core/lending.py — get_loans_of_user, _get_ia_loans_of_user, IA_Lending_API
  • openlibrary/plugins/upstream/account.py — get_loan_history_data for user_borrow_history

Requirements Checklist

  • [ ] Fetch active loans via get_loans_of_user in mybooks.py
  • [ ] Fetch historical loans via the user_borrow_history action on the lending API
  • [ ] Deduplicate merged list by OLID (active loan wins)
  • [ ] Sort merged list by last-access timestamp descending
  • [ ] Limit to a sensible maximum (e.g. 18 books)
  • [ ] Update mybooks.html to render the unified list in the carousel
  • [ ] Ensure cards correctly handle redirect keys (/books/ia:xxx → /books/OLxxx) for covers

Stakeholders

  • @Sadashii (author, implementation lead)
  • @mekarpeles (maintainer review)

Instructions for Contributors

Sadashii avatar Aug 06 '26 17:08 Sadashii

Thanks for the suggestion! A staff member will review this and follow up when they can.

openlibrary-bot avatar Aug 06 '26 17:08 openlibrary-bot