Skip to content

refactor(server): extract the artist-alias routes into routers/artist_aliases.py (R3) - #838

Merged
byrongamatos merged 2 commits into
mainfrom
refactor/r3-router-artist-aliases
Jul 10, 2026
Merged

refactor(server): extract the artist-alias routes into routers/artist_aliases.py (R3)#838
byrongamatos merged 2 commits into
mainfrom
refactor/r3-router-artist-aliases

Conversation

@byrongamatos

@byrongamatos byrongamatos commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Second router in the R3 train, after audio-effects (#834). Move-only, backend-only.

Picked by measurement

router_scan.py ranks the artist-aliases / Tidy-up (P4) group at 0 monkeypatch.setattr targets and 0 helpers to relocate — its only dependencies are JSONResponse, app, and meta_db. 5 routes, all meta_db-only:

  • GET /api/artist-aliases · GET /api/artists/raw · POST /api/artist-aliases · POST /api/artist-aliases/merge · DELETE /api/artist-aliases/{raw_name:path}

What changed

Bodies verbatim. Two mechanical edits: @app.<m>@router.<m>, meta_dbappstate.meta_db (a module attribute at call time, so a re-imported server re-publishes a fresh DB into the seam). include_router mounts at the original site.

server.py: 9,386 → 9,337.

Verification

  • Route table identical to origin/main — 143 routes, same paths/methods/registration order.
  • No test retargeting: test_artist_alias drives via TestClient(server.app) + server.meta_db, neither of which moved. 18 tests pass.
  • Boot smoke drives all 5 routes end-to-end: set ACDC → AC/DC, read it back, 400 on missing fields, delete.
  • pytest 2398 passed; packaging guard green (tests/test_packaging.py sees the new router); pyflakes clean; JSONResponse still used in server.py (didn't go dead); npm run lint 0 errors.
  • Codex preflight: 0 findings.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added/organized artist alias management endpoints (view, create/upsert, merge, delete) with validation and conflict handling.
    • Added an endpoint to browse raw artist names with song counts and canonical selections.
  • Refactor
    • Moved artist alias route handling into a dedicated router module and mounted it at the existing route location.
  • Documentation
    • Updated the changelog with progress on backend route-layer extraction.
    • Updated static size exemption line-count metrics in the documentation.

…_aliases.py (R3)

Second router, picked by router_scan.py: the artist-aliases / Tidy-up (P4) group
ranks at 0 monkeypatch.setattr targets and 0 helpers to relocate. 5 routes
(list/set/merge/delete aliases + raw-artist picker), all meta_db-only.

Bodies verbatim; only @app.<m> -> @router.<m> and meta_db -> appstate.meta_db.
include_router mounts at the original site; full 143-route table identical to
origin/main (paths, methods, order). No test retargets: test_artist_alias drives
via TestClient(server.app) + server.meta_db, neither of which moved.

Verified: pyflakes clean on the router; no new undefined in server.py; JSONResponse
still used in server.py (not dead); pytest 2398 passed (18 in test_artist_alias);
packaging guard green; eslint 0; boot smoke drives all 5 routes end-to-end
(set ACDC->AC/DC, read back, 400 on missing fields, delete).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@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: db835fef-1b3a-4be7-9d5f-522dc4b0c9ac

📥 Commits

Reviewing files that changed from the base of the PR and between e572a0a and ede9bae.

📒 Files selected for processing (1)
  • docs/size-exemptions.md
✅ Files skipped from review due to trivial changes (1)
  • docs/size-exemptions.md

📝 Walkthrough

Walkthrough

The artist alias API routes were extracted from server.py into lib/routers/artist_aliases.py, where they use APIRouter and appstate.meta_db. server.py mounts the new router, while changelog and size-exemption records are updated.

Changes

Artist aliases API extraction

Layer / File(s) Summary
Artist alias router endpoints
lib/routers/artist_aliases.py
Adds GET, POST, merge, and DELETE handlers for artist aliases and raw artists, including validation and database operations.
Router mounting and extraction records
server.py, CHANGELOG.md, docs/size-exemptions.md
Mounts the extracted router in server.py and updates the changelog and recorded frontend line count.

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 artist-alias routes from server.py into routers/artist_aliases.py.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/r3-router-artist-aliases

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 `@docs/size-exemptions.md`:
- Line 58: Update the rationale for the 9,337 size count in
docs/size-exemptions.md to credit both router extractions, explicitly mentioning
this PR’s artist_aliases extraction alongside the first routers module.
🪄 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: d9e1ce5b-8a32-4233-b07e-26b5b0662d85

📥 Commits

Reviewing files that changed from the base of the PR and between b321569 and e572a0a.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • docs/size-exemptions.md
  • lib/routers/artist_aliases.py
  • server.py

Comment thread docs/size-exemptions.md
@byrongamatos
byrongamatos merged commit 6c98aba into main Jul 10, 2026
4 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