openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

2733/feature/show editions in reading log

Open benbdeitch opened this issue 1 year ago • 0 comments

Closes #2733

This PR alters how the 'already-read' and 'currently-read' bookshelves retrieve and display items. Rather than simply fetching the work data, they now retrieve the edition-specific data that is already stored in their reading log.

Currently, the 'want-to-read' bookshelf is untouched, as users might want to know when any edition becomes available to borrow.

Technical

The get_users_logged_books function in openlibrary/core/Bookshelves was edited to provide this functionality. Based on the bookshelf_id received, it switches on editions variable, that is used to later define behavior.

Both the get_sorted_reading_log_books and get_filtered_reading_log_books were altered to switch between fetching work data, or fetching work and edition data, based on the 'editions' variable. As well, a new function, link_editions_to_works was created to process the retrieved results, and properly tie them together, so that they are correctly interpreted by the SearchResultsWork macro.

Testing

To verify, simply add a few books to each shelf of your reading log. Preferably, editions with titles that differ from the work's should be chosen, or a brief edit in macro/SearchResultsWork can be used to display the doc_type variable. On each shelf, one should both check the shelf as a whole (which uses the 'get_sorted_reading_log_books' function, and attempt to search for an individual work (using the get_filtered_reading_log_books function).

Screenshot

image image

(As noted, the 'solr_edition' line is not a part of the pull-request; merely an easy way to display the doc_type variable for testing.)

image image

Stakeholders

@cdrini

benbdeitch avatar Feb 14 '24 17:02 benbdeitch