Skip to content

refactor(server): extract the wishlist routes into routers/wanted.py (R3) - #847

Merged
byrongamatos merged 1 commit into
mainfrom
refactor/r3-router-wanted
Jul 10, 2026
Merged

refactor(server): extract the wishlist routes into routers/wanted.py (R3)#847
byrongamatos merged 1 commit into
mainfrom
refactor/r3-router-wanted

Conversation

@byrongamatos

@byrongamatos byrongamatos commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Free after _clean_str moved to lib/reqfields.py (#841): wanted's deps are JSONResponse, _clean_str, app + meta_db (seam). 0 setattr targets, 0 helpers. 3 routes (list/add/remove).

Bodies verbatim; include_router at the original site; 143-route table identical. No test retargeting. server.py: 8,003 → 7,974 (independent branch off origin/main, parallel to the chart PR #846 — the register line will need reconciling for whichever merges second).

Verification

  • Route table identical; no newly-dead imports; pyflakes clean.
  • pytest 2401 passed (52 in test_wanted_api); npm run lint 0.
  • Boot smoke: add wishlist entry → list → delete; 400 on missing artist+title.
  • Codex: 0 findings.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a wishlist API to view, add, and remove wanted items.
    • Included request validation for wishlist entries (requires artist or title), plus support for optional source and notes.
  • Documentation

    • Updated documented size and extraction totals for the server component.
  • Refactor

    • Reorganized wishlist API route handling by moving endpoint implementations into a dedicated router module.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f17d8998-f964-4b73-a663-3f5ece223385

📥 Commits

Reviewing files that changed from the base of the PR and between f0ab584 and 4525a92.

📒 Files selected for processing (3)
  • docs/size-exemptions.md
  • lib/routers/wanted.py
  • server.py
✅ Files skipped from review due to trivial changes (1)
  • docs/size-exemptions.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • server.py
  • lib/routers/wanted.py

📝 Walkthrough

Walkthrough

The wishlist API handlers moved from server.py into lib/routers/wanted.py. The server now mounts the dedicated router, and size-exemption documentation reflects the updated line count and router total.

Changes

Wanted API router extraction

Layer / File(s) Summary
Wanted router endpoints
lib/routers/wanted.py
Adds list, add, and remove wishlist endpoints with input validation, field normalization, and datastore delegation.
Server router mounting
server.py, docs/size-exemptions.md
Imports and mounts the wanted router, removes the inline handlers, and updates server size accounting.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: extracting the wishlist routes from server.py into routers/wanted.py.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/r3-router-wanted

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/routers/wanted.py`:
- Line 19: The MetadataDB.list_wanted() method reads the shared SQLite
connection without synchronization. Wrap its SELECT/query operation in with
self._lock:, matching add_wanted() and remove_wanted(), so concurrent
wanted-list reads are serialized with writes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 98a3a51a-7068-4ae0-94ab-8579ced997f0

📥 Commits

Reviewing files that changed from the base of the PR and between c870199 and f0ab584.

📒 Files selected for processing (3)
  • docs/size-exemptions.md
  • lib/routers/wanted.py
  • server.py

Comment thread lib/routers/wanted.py
@byrongamatos

Copy link
Copy Markdown
Contributor Author

The unlocked list_wanted() read is real and pre-existing in lib/metadata_db.py, which this move doesn't touch — the wanted routes just call meta_db.list_wanted(). Same class as the loops read-lock fix (#840). I'll add with self._lock: there in a small follow-up alongside any sibling unlocked reads, rather than ride it on a route move. Low severity in context (single-user, Principle I).

…(R3)

Free after _clean_str moved to lib (#841): wanted's deps are JSONResponse,
_clean_str (reqfields), app + meta_db (seam). 3 routes (list/add/remove),
0 setattr targets, 0 helpers to relocate.

Bodies verbatim; @app -> @router, meta_db -> appstate.meta_db. include_router at
the original site; 143-route table identical. No test retargeting.

server.py: 8,003 -> 7,974 (this branch is independent of the chart PR).

Verified: pyflakes clean; route table identical; pytest 2401 passed (52 in
test_wanted_api); eslint 0. Boot smoke: add wishlist entry -> list -> delete,
400 on missing artist+title (_clean_str path).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@byrongamatos
byrongamatos force-pushed the refactor/r3-router-wanted branch from f0ab584 to 4525a92 Compare July 10, 2026 20:16
@byrongamatos
byrongamatos merged commit cbc6545 into main Jul 10, 2026
5 checks passed
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.

1 participant