Repository navigation
fix: a deleted user's shelves and watched lists stop creating requests - #521
Merged
Merged
Conversation
Shelves (Goodreads, Hardcover) and watched series and authors whose user has deletedAt set are dropped right after the load: no fetch, scrape or Audible lookup, no request, no shelf or watch write, also on a run scoped to that user. Each pass logs one line with the number skipped when any are. find_missing_ebooks leaves out a deleted user's audiobook requests in its candidate query, so no ebook request is created or retried for them. Rows and existing requests are kept. Closes #504. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #504
What changed
User.deletedAtset) is skipped by the scheduled and manual runs. No feed or list fetch, no Audible scrape or lookup, no request, no shelf or watch write. This holds for every login provider and for runs scoped to one user or one shelf.withoutDeletedUsers()(src/lib/utils/deleted-user-skip.ts) drops those rows right after the load and logs one line with the count when any are skipped, e.g.Skipped 2 watched series whose user is deleted. Nothing is logged when none are.src/lib/services/watched-lists.service.ts): the series and author passes load each watch'suser.deletedAtand skip deleted users' watches. A series or author watched only by deleted users is no longer scraped; one also watched by an active user is scraped once, as before, and only the active user's watch gets requests and alastCheckedAtupdate.src/lib/services/goodreads-sync.service.ts,src/lib/services/hardcover-sync.service.ts): same skip before any fetch. "Shelf not found" / "No shelves configured" is only logged when the load found nothing at all.src/lib/processors/find-missing-ebooks.processor.ts): the candidate query joinsusersand requiresu.deleted_at IS NULL, sofind_missing_ebooksno longer creates or retries ebook requests for a deleted user, and their audiobook requests no longer use slots of the 50-per-run limit.documentation/features/watched-lists.md(Sync Flow),documentation/backend/services/goodreads-sync.md(new Deleted Users section),documentation/backend/services/hardcover-sync.md(Sync Flow),documentation/backend/services/scheduler.md(find_missing_ebooks, Fixed Issues),documentation/TABLEOFCONTENTS.md.Why
Deleting a user sets
deletedAtand keeps their rows. The shelf sync and watched-list check loaded every shelf and watch with no user filter, so a deleted user's Goodreads and Hardcover shelves and watched series and authors kept being fetched every cycle and kept creating new requests in their name.find_missing_ebooksdid the same for ebook companions of their downloaded audiobooks.Other background jobs checked
audible_refreshstill scrapes the Audible categories on a deleted user's home sections (UserHomeSection). It creates no requests, so it is left as is.retry_missing_torrents,retry_failed_imports,monitor_rss_feeds, the library scans and the download pipeline act on existing requests, which this change leaves untouched. When a deleted user's in-flight audiobook finishes, the organizer still adds its ebook companion as part of that request.Evidence
tests/services/watched-lists-deleted-user.test.ts: a deleted and an active user watch the same series (and the same author), and the deleted user watches one more on their own. Only the shared one is scraped, only the active user gets a request and alastCheckedAtupdate, and the skip count is logged. A run scoped to the deleted user scrapes, requests and writes nothing.tests/services/shelf-sync-deleted-user.test.ts: a deleted and an active user's Goodreads shelves, and the same for Hardcover lists. Only the active feed or list is fetched and looked up on Audible, only the active user gets a request and a shelf update, and the skip count is logged. A run scoped to the deleted user fetches, looks up and writes nothing. Both suites also check that the load selectsdeletedAt.tests/processors/find-missing-ebooks-deleted-user.test.ts: the candidate query joinsusersand filtersu.deleted_at IS NULLinside the WHERE that the LIMIT applies to.main'ssrc(efcccc9) and the three new test files: 11 failed and 1 passed, all on an assertion (the deleted user's feed, list, series and author fetched; requests created for them;deletedAtnot selected; no users join). The one that passes is the check that no skip line is logged when no user is deleted.Checks
vitest relatedon the five changedsrcfiles, plus the new and updated test files): PASS, 98 files, 1213/1213tsc --noEmitclean; ESLint reports nothing new in the touched files compared withmain, and the new files are clean)Risk and rollback
deletedAt) in each load.lastSyncAt/lastCheckedAtstay at the last run before the delete.find_missing_ebooksnow adds an inner join tousers;requests.user_idis required with a foreign key, so no active user's request drops out.Release note
🤖 Generated with Claude Code