-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show editions in reading log #8821
Show editions in reading log #8821
Conversation
…d_books to allow for edition retrieval.
…og working properly.
for more information, see https://pre-commit.ci
…logged_books' function, to adhere to the line limit.
I bump into this problem often and this would totally fix it for me. Thanks for implementing this @benbdeitch! |
…s' value for get_sorted_reading_log_books was false. As well, updated the error message to reflect the change in a variable's name.
…ored in the list comprehension for searching Solr's index through get_sorted_reading_log_books.
… for redirects to properly function when linking retrieved methods to works.
… for add_storage_items_for_redirects to query Solr for a work containing the edition, if it has the edition data, but the work is a redirect.
@benbdeitch how is it going with this? Do you need any help? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great! A few code cleanups, and one potential error! Will take a look at the last method afterwards.
Testing:
This page seems to error: https://testing.openlibrary.org/people/bigdbag/books/already-read?page=10&debug=true
✅ sort | edition_id=null | https://testing.openlibrary.org/people/pyat/books/already-read
✅ filter | edition_id=null | https://testing.openlibrary.org/people/pyat/books/already-read?q=playground
✅ sort | large reading log | https://testing.openlibrary.org/people/bigdbag/books/already-read
✅ filter | large reading log | https://testing.openlibrary.org/people/bigdbag/books/already-read?q=harry+potter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the finished review!
…es, and providing more descriptive variable names.
… avoid individual solr calls for each necessary key.
for more information, see https://pre-commit.ci
…sorted books for retrieving a user's bookshelves.
…m:benbdeitch/openlibraryfork into 2723/feature/show-editions-in-reading-log
…nfogami.infobase.utils
… missing keys to unpack, and filtered the None keys out in the solr.get_many request.
…og_books, when only specific editions were needed.
…eading_log_books method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok lgtm! I tested redirects; there is one edge case when you add two works and then the two works are merged... but I think it's very edge case and I'm not too sure how we should handle it. It does work correctly when you add a work/edition and then that work gets merged into another. Also works if you add just a work, and it gets merged into another -- displays the empty tile it currently displays.
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 oneditions
variable, that is used to later define behavior.Both the
get_sorted_reading_log_books
andget_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 theSearchResultsWork
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 thedoc_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 theget_filtered_reading_log_books
function).Screenshot
(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.)
Stakeholders
@cdrini