Skip to content

feat: add 'Stopped Reading' bookshelf and related functionality - #12400

Merged
mekarpeles merged 17 commits into
internetarchive:masterfrom
Sadashii:feature/stopped-reading-bookshelf
May 31, 2026
Merged

feat: add 'Stopped Reading' bookshelf and related functionality#12400
mekarpeles merged 17 commits into
internetarchive:masterfrom
Sadashii:feature/stopped-reading-bookshelf

Conversation

@Sadashii

@Sadashii Sadashii commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

Closes #2016

Description

Introduces a new "Stopped Reading" bookshelf (ID: 4). It works similar to the existing "Want to Read", "Currently Reading", and "Already Read" shelves, allowing patrons to track books they have paused reading. The implementation spans the database, Solr indexing, the Python backend, and the frontend templates to ensure the new shelf integrates seamlessly into the patron experience.

Technical

Database & Backend (openlibrary/core, openlibrary/plugins, etc.)

  • Added Stopped Reading to Bookshelves.PRESET_BOOKSHELVES and updated relevant mapping dictionaries and enums.
  • Updated Bookshelves.most_logged_books and Bookshelves.get_recently_logged_books to support filtering via a list of shelf_ids (using the IN operator) rather than a single shelf_id.
  • Added stopped-reading logic to mybooks.py routes, templates, and the ReadingLog class.

Search & Solr (openlibrary/solr, conf/solr)

  • Added stopped_reading_count to managed-schema.xml.
  • Updated author.py, solr_types.py, data_provider.py, and works.py to index, tally, and allow sorting by the stopped_reading_count.

Frontend & UI Updates (openlibrary/templates)

  1. StarRatingsStats.html: Added the shelf analogous to the rest so "x Stopped Reading" appears on the /works/<work_id> page.
  2. /people//books Updates:
    mybooks.html: Added a carousel for the new shelf to the main view.
    sidebar.html: Added the shelf to the left sidebar.
    mybooks_breadcrumb_select.html: Added the shelf to the page selector next to the account name.
    topmenu.html: Added the shelf to the internal filter. This ensures the ‘My Reading Stats’, ‘Import/Export’, and ‘Privacy Settings’ buttons remain visible on the bookshelf and mybooks pages.
  3. privacy.html: Updated the description string in /account/privacy to include the new shelf.
  4. primary_action.html: Updated the primary action button text on the /works/<work_id> page to reflect the correct bookshelf state when a user has a book marked as "Stopped Reading".
  5. dropdown_content.html: Added the "Stopped Reading" option to the dropper menu used to update book locations (shelves/lists).
  6. type/user/view.html: Added the "Stopped Reading" link and description for public profiles on the /people/ page (handling both the owner's view and other users' views).
  7. readinglog_shelf_name.html: Added the display name text for /people//books/stopped-reading/stats.
  8. reading_log.html: Added the shelf name to correctly handle the valid bookshelf and show the correct Open Graph (OG) meta tags.
  9. sort_options.html: Added the "Stopped Reading" shelf to the search sort options.
  10. ReadingLogForms.js & check_in_prompt.html: Added the new shelf variable/ID to scripts and template comments for consistency.

Note: The /trending Page Feed
Currently, the /trending page fetches recently logged books from all bookshelves. With the addition of this new shelf, the live feed would begin showing updates like: "Someone stopped reading [Book] x minutes ago", which feels counterintuitive for a "Trending" feed. It would also artificially inflate the "Logged x times" metrics for daily/weekly trends.
Solution implemented: Updated get_recently_logged_books and cached_get_most_logged_books to allow the bookshelf_id parameter to be passed as a list (shelf_ids). In loanstats.py, the database queries for the trending page now explicitly filter only for IDs 1, 2, and 3 (Want to Read, Currently Reading, Already Read), effectively filtering out the "Stopped Reading" shelf from the trending logic.

Database Migration

To upgrade an existing database, you must connect to PostgreSQL and manually run the following SQL insert statement to populate the default bookshelf:

INSERT INTO bookshelves (name, description) VALUES ('Stopped Reading', 'A list of books I have stopped reading');

(Note: The schema.sql and dev_db.pg_dump files have been updated for fresh setups).

Testing

  1. Connect to your local PostgreSQL instance and run the manual SQL insert command above to add the new shelf.
  2. Navigate to any Work page (/works/<work_id>). Use the dropdown menu to mark the book as "Stopped Reading". Verify that the primary action button and the reader stats ("x Stopped Reading") update accordingly.
  3. Navigate to your reading log (/people//books). Verify the new "Stopped Reading" carousel is visible, the shelf appears in the left sidebar, and it is available in the page selector.
  4. Navigate to /trending and /trending/now. Verify that the book you just marked as "Stopped Reading" does not appear in the activity feed or influence the most-logged metrics.
  5. Check /account/privacy to verify the updated description string.
  6. Check your profile from an incognito window (or another account) to verify the correct display behavior for public vs. private reading logs.

Screenshots

StarRatingStats [UI Update 1] -
Old:
image
New: Will also show the x Stopped Reading count
image

My Books Page [UI Update 2]
image

Privacy Page [UI Update 3]
image

Primary Action Button [UI Update 4]
image

Book Location Dropper [UI Update 5]
image

User Profile Page for public users [UI Update 6]
Owner's view:
image
Visitor's view:
image

Display name of shelf on stopped reading stats page [UI Update 7]
image

Stakeholders

@mekarpeles

Copilot AI review requested due to automatic review settings April 17, 2026 16:19
@mekarpeles mekarpeles added the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label Apr 17, 2026
@mekarpeles

Copy link
Copy Markdown
Member

Thanks for the PR, @Sadashii!

Copilot has been assigned for an initial review.

@mekarpeles is assigned to this PR and currently has:

  • 1 open PR(s) of equal or higher priority to review first

Possible improvements for this PR

  • Tests: The PR modifies substantive backend logic (bookshelves, mybooks routes, solr indexing) but no test files were found in the diff. Consider adding test coverage for the new shelf behavior, or note in the PR body why tests are not applicable.
PR triage checklist (maintainers / Pam)
  • PR description — not empty; explains what the change does and how to verify it
  • References an issue — PR body contains a #NNN reference
    • Linked issue is triaged — has a Priority: * label (not just Needs: Triage)
    • Linked issue is assigned — has at least one assignee
  • Commit history clean — no WIP/fixup/conflict noise; commit messages are meaningful
  • CI passing — no failing check-runs
  • Test cases present — if the change touches substantive logic, test coverage exists or is explained
  • Proof of testing — PR body includes a description of what was tested, a screenshot, or a video

Note

This comment was automatically generated by Pam, Open Library's Project AI Manager, on behalf of @mekarpeles. Pam is designed to provide status visibility, perform basic project management functions and relevant codebase research, and provide actionable feedback so contributors aren't left waiting.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new preset Reading Log shelf (“Stopped Reading”, intended ID: 4) and wires it through the database defaults, backend reading-log/trending logic, Solr schema/index types, and multiple UI surfaces so users can mark and view books they’ve stopped reading.

Changes:

  • Introduces preset shelf ID 4 (“Stopped Reading”) across DB seed data, backend constants, and reading-log UI templates/actions.
  • Extends trending + reading-log querying/indexing/sorting to recognize stopped-reading counts and (for the HTML trending page) filter stopped-reading out of trending activity.
  • Updates Solr schema/types and worksearch sort options to support stopped_reading_count and sorting by it.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/dev-instance/dev_db.pg_dump Seeds the dev DB with bookshelf ID 4 row.
openlibrary/views/loanstats.py Updates trending functions/caching signatures and filters HTML trending page to shelves 1–3.
openlibrary/templates/type/user/view.html Adds “stopped-reading” link to public Reading Log blurb.
openlibrary/templates/trending.html Adds shelf label for ID 4 in activity rendering and adjusts displayed timestamp field.
openlibrary/templates/search/sort_options.html Adds “Stopped Reading” as a Reading Log sub-sort option.
openlibrary/templates/my_books/primary_action.html Updates primary CTA label for read_status == 4.
openlibrary/templates/my_books/dropdown_content.html Adds “Stopped Reading” option to the reading-log dropper UI.
openlibrary/templates/my_books/check_ins/check_in_prompt.html Documents shelf ID 4 in template comments.
openlibrary/templates/books/mybooks_breadcrumb_select.html Adds “Stopped Reading” to breadcrumb shelf selector.
openlibrary/templates/account/topmenu.html Treats stopped-reading as a readinglog view for top menu rendering.
openlibrary/templates/account/sidebar.html Adds “Stopped Reading” link + count to My Books sidebar.
openlibrary/templates/account/readinglog_shelf_name.html Adds display name mapping for stopped-reading.
openlibrary/templates/account/reading_log.html Adds stopped-reading handling for OG/meta and shelf mapping.
openlibrary/templates/account/privacy.html Updates privacy copy to include stopped-reading.
openlibrary/templates/account/mybooks.html Adds stopped-reading carousel to My Books page.
openlibrary/solr/updater/author.py Adds stopped-reading facet aggregation into author solr updates.
openlibrary/solr/solr_types.py Adds stopped_reading_count to SolrDocument typing.
openlibrary/solr/data_provider.py Extends reading-log Solr summary typing with stopped-reading count.
openlibrary/plugins/worksearch/schemes/works.py Adds field + sort mapping for stopped_reading_count.
openlibrary/plugins/upstream/mybooks.py Extends reading-log routes/keys and My Books template context with stopped-reading.
openlibrary/plugins/upstream/account.py Updates Reading Log CSV export bookshelf name mapping to include ID 4.
openlibrary/plugins/openlibrary/js/my-books/MyBooksDropper/ReadingLogForms.js Adds STOPPED_READING shelf constant for client-side forms.
openlibrary/macros/StarRatingsStats.html Shows “Stopped reading” count in work stats component.
openlibrary/fastapi/public_my_books.py Extends FastAPI reading-log key Literal to include stopped-reading.
openlibrary/core/schema.sql Seeds new bookshelf row for fresh DBs.
openlibrary/core/models.py Adds stopped-reading to work “num users by bookshelf” mapping.
openlibrary/core/bookshelves.py Adds shelf ID 4 to preset mappings and updates query helpers to accept lists of shelf IDs.
conf/solr/conf/managed-schema.xml Adds stopped_reading_count field to Solr schema.

Comment thread openlibrary/views/loanstats.py
Comment thread openlibrary/templates/trending.html Outdated
Comment thread openlibrary/templates/type/user/view.html Outdated
Comment thread openlibrary/views/loanstats.py
@github-actions github-actions Bot removed the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label Apr 17, 2026
@Sadashii
Sadashii requested a review from Copilot April 17, 2026 16:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 5 comments.

Comment thread openlibrary/views/loanstats.py
Comment thread openlibrary/plugins/upstream/mybooks.py
Comment thread conf/solr/conf/managed-schema.xml
Comment thread openlibrary/views/loanstats.py
Comment thread openlibrary/views/loanstats.py
@Sadashii

Copy link
Copy Markdown
Collaborator Author

@copilot apply changes based on the comments in this thread

@github-actions github-actions Bot added the Needs: Response Issues which require feedback from lead label Apr 19, 2026
@mekarpeles

Copy link
Copy Markdown
Member

The different reading log pages are currently broken with this PR; see testing:
https://testing.openlibrary.org/people/mekBot/books/currently-reading

@Sadashii
Sadashii force-pushed the feature/stopped-reading-bookshelf branch from 612759f to d97a584 Compare April 22, 2026 01:59
@jimchamp jimchamp added the Needs: Special Deploy This PR will need a non-standard deploy to production label Apr 23, 2026
Comment thread openlibrary/core/schema.sql
@Sadashii
Sadashii force-pushed the feature/stopped-reading-bookshelf branch 2 times, most recently from 3aa0153 to 78ac0fa Compare May 5, 2026 16:36
@mekarpeles

Copy link
Copy Markdown
Member

On https://testing.openlibrary.org/people/mekBot/books/stopped-reading

/openlibrary/openlibrary/templates/my_books/primary_action.html: error in processing template: UnboundLocalError: cannot access local variable 'track_value' where it is not associated with a value (falling back to default template)

There may be spots where the Reading Log Dropper have not been updated. Or possibly Partials.

image

@mekarpeles mekarpeles removed the Needs: Response Issues which require feedback from lead label May 6, 2026
@mekarpeles mekarpeles added the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label May 6, 2026
@Sadashii
Sadashii force-pushed the feature/stopped-reading-bookshelf branch from 39dd2b7 to df5d975 Compare May 11, 2026 17:18
@github-actions github-actions Bot removed the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label May 11, 2026
@Sadashii
Sadashii force-pushed the feature/stopped-reading-bookshelf branch from df5d975 to ea56220 Compare May 11, 2026 17:23
@RayBB

RayBB commented May 20, 2026

Copy link
Copy Markdown
Collaborator

Just fixed a merge conflict for you caused by #12778

@mekarpeles
mekarpeles merged commit 56a2586 into internetarchive:master May 31, 2026
4 of 5 checks passed
Comment thread conf/solr/conf/managed-schema.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Special Deploy This PR will need a non-standard deploy to production

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A Reading Log option for "Stopped Reading"

6 participants