Skip to content

unbreak my books for deleted books #11027

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mekarpeles
Copy link
Member

Closes #10970

Technical

My Books reading log pages breaks when books deleted; a deletion should probably cascade and remove related books from reading log table (similar to how we update redirects). In the interim, this solution should unbreak book pages by changing the assertion to an if check.

Testing

Tested on testing.

Screenshot

Stakeholders

@Copilot Copilot AI review requested due to automatic review settings July 15, 2025 20:53
@mekarpeles mekarpeles added the Patch Deployed This PR has been deployed to production independently, outside of the regular deploy cycle. label Jul 15, 2025
@github-actions github-actions bot added the Priority: 1 Do this week, receiving emails, time sensitive, . [managed] label Jul 15, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where the "My Books" reading log page would crash when books referenced in the reading log had been deleted. Instead of asserting that all reading log items exist in Solr, it now gracefully handles missing books by logging warnings.

Key changes:

  • Replaces a hard assertion with a conditional check for missing books
  • Adds logging to track which books are missing from Solr
  • Prevents page crashes when deleted books are referenced in reading logs

"see add_storage_items_for_redirects()"
)
if len(solr_docs) <= len(reading_log_keys):
missing = set(w for w, e in reading_log_keys) - set([doc['key'] for doc in solr_docs])
Copy link
Preview

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

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

Use set comprehension instead of list comprehension wrapped in set(). Change set([doc['key'] for doc in solr_docs]) to {doc['key'] for doc in solr_docs} for better performance.

Suggested change
missing = set(w for w, e in reading_log_keys) - set([doc['key'] for doc in solr_docs])
missing = set(w for w, e in reading_log_keys) - {doc['key'] for doc in solr_docs}

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Patch Deployed This PR has been deployed to production independently, outside of the regular deploy cycle. Priority: 1 Do this week, receiving emails, time sensitive, . [managed]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Want to Read section doesn't display books and shows error
2 participants