Skip to content

fix: a deleted user's shelves and watched lists stop creating requests - #521

Merged
kikootwo merged 1 commit into
mainfrom
fix/504-deleted-user-automation
Nov 2, 2026
Merged

kikootwo merged 1 commit into
mainfrom
fix/504-deleted-user-automation

Conversation

@kikootwo

@kikootwo kikootwo commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Closes #504

What changed

  • Rule: a shelf (Goodreads, Hardcover) or a watch (series, author) whose user is deleted (User.deletedAt set) 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.
  • New helper 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.
  • Watched lists (src/lib/services/watched-lists.service.ts): the series and author passes load each watch's user.deletedAt and 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 a lastCheckedAt update.
  • Shelves (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.
  • Ebook backfill (src/lib/processors/find-missing-ebooks.processor.ts): the candidate query joins users and requires u.deleted_at IS NULL, so find_missing_ebooks no longer creates or retries ebook requests for a deleted user, and their audiobook requests no longer use slots of the 50-per-run limit.
  • Shelf and watch rows are kept (a user delete is a soft delete), and so are the user's existing requests.
  • Docs: 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 deletedAt and 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_ebooks did the same for ebook companions of their downloaded audiobooks.

Other background jobs checked

  • audible_refresh still 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 a lastCheckedAt update, 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 selects deletedAt.
  • tests/processors/find-missing-ebooks-deleted-user.test.ts: the candidate query joins users and filters u.deleted_at IS NULL inside the WHERE that the LIMIT applies to.
  • With main's src (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; deletedAt not selected; no users join). The one that passes is the check that no skip line is logged when no user is deleted.
  • On this branch, the three new test files: 12/12 pass.

Checks

  • Unit tests for the changed code (vitest related on the five changed src files, plus the new and updated test files): PASS, 98 files, 1213/1213
  • Type check and lint: PASS (tsc --noEmit clean; ESLint reports nothing new in the touched files compared with main, and the new files are clean)
  • No image build or E2E run: no visible change
  • Full unit suite: PR Tests (CI)

Risk and rollback

  • Active users' shelves and watches run exactly as before. The only extra work is one more column (deletedAt) in each load.
  • A deleted user's shelves and watches stop syncing at once. Their lastSyncAt / lastCheckedAt stay at the last run before the delete.
  • find_missing_ebooks now adds an inner join to users; requests.user_id is required with a foreign key, so no active user's request drops out.
  • Rollback: revert this PR. Nothing stored is changed.

Release note

🤖 Generated with Claude Code

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>
@kikootwo
kikootwo merged commit 1cd7af0 into main Nov 2, 2026
1 check passed
@kikootwo
kikootwo deleted the fix/504-deleted-user-automation branch November 2, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A deleted user's watched lists and shelves keep creating requests

1 participant