Skip to content

My Books: Borrow History Page #7311

@mekarpeles

Description

@mekarpeles

Background

Please refer to the My Books Development Tutorial to provide background on which changes may be required:
https://github.com/internetarchive/openlibrary/wiki/Developing-the-Reading-Log

Problem

At the time of authoring this issue, there was no Archive.org API for fetching a patron's loan history so, instead of rendering a loan_history page on Open Library under the my books page, we had to link patrons to their archive.org account:

Screenshot 2023-09-12 at 8 59 00 AM

On Archive.org - My Loan History experience

  1. Going to https://archive.org/account/?tab=loans#loans-history did not switch to history tab (no way to navigate directly)
  2. History was not sorted from most recent borrow to least
  3. No way to change the sort order
  4. No way to search for a title to re-borrow
  5. No way to segment by year borrowed
  6. No API (I can see) to improve this experience

The things I'm trying to do are:

  1. See books I've borrowed (preferably recently, to continue)
  2. Search for a specific title
  3. See whether these titles are available

Unofficial Docs

We should eventually create an endpoint https://archive.org/services/loans/loan/?action=history which takes s3_secret and s3_access (as POST / headers).

image

Proposal & Constraints

Implement borrow history (private) on Open Library which uses s3 keys + archive.org API

Add search (by title / author), year separators, show recently borrowed first.

Developer Notes

/plugins is a directory containing python code which allows us to define new pages or URLs that we want to register for Open Library. So, imagine we want to create a new page that doesn't exist yet called /{account-name}/books/loan-history -- we can register a python function in a plugin that:

  1. defines a URL (e.g. /{account-name}/books/loan-history) the patron will go
  2. defines what data models will be used to fetch the data our page will need
  3. calls and renders an html template, giving it the data we've fetched

Steps:

  1. Add a new plugin for /{account-name}/books/loan-history to the my books: https://github.com/internetarchive/openlibrary/blob/master/openlibrary/plugins/upstream/mybooks.py
  2. In this plugin function, we're going to fetch the logged in patron, use the borrow_history API to fetch their historical loans
  3. Add a new html template into https://github.com/internetarchive/openlibrary/tree/master/openlibrary/templates/account directory for loan_history.html (you may use loans.html as a reference because its very similar to what we want to do)
  4. The plugin will fetch borrow_history API and pass the result into loan_history.html
    • There may be 1 "gotcha" which is, in templates/account there's a file called mybooks.html which wraps around the loans page and the loan_history page we're going to be creating -- it's what renders the sidebar for the my books page.

Stakeholders

@bfalling

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions