chore: dedupe is_unique_violation, lift SQL into repo, centralise URL parsing
Three layering cleanups from REVIEW.md §5 / §3:
- Drop the three private `is_unique_violation` helpers in
repo::{user,chapter,bookmark} in favour of sqlx 0.8's
`DatabaseError::is_unique_violation()` method (already used by
repo::collection).
- Remove the unreachable 23505 branch in repo::chapter::create — the
(manga_id, number) UNIQUE was dropped in 0013, so the defensive arm
could no longer fire. A doc note records what to do if uniqueness
is re-added.
- Move three inline SQL queries out of handlers/daemon into repo
functions: bookmarks' chapter-belongs-to-manga guard
(`repo::chapter::belongs_to_manga`), the daemon's dispatch lookup
(`repo::chapter::dispatch_target`), and the daemon's page_count
safety net (`repo::chapter::page_count`). Restores the
handlers→repo layering invariant in CLAUDE.md.
- New `crawler::url_utils` module consolidates host_of / origin_of /
registrable_domain — they used to live in three crawler submodules
with diverging edge-case behaviour. Tests moved with them.
- Doc cross-references on repo::author::set_for_manga and
repo::genre::set_for_manga pointing to the crawler's name-keyed
variants, so the intentional duplication is discoverable.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -99,6 +99,11 @@ pub async fn list(
|
||||
/// Atomically replace the set of authors on a manga. Caller passes a
|
||||
/// `&mut PgConnection` (`&mut *tx` works) so the delete+upserts run in
|
||||
/// one transaction with whatever called us.
|
||||
///
|
||||
/// Note: `crawler::repo::sync_authors` does a similar replace with the
|
||||
/// same semantics on names. The duplication is intentional — handler
|
||||
/// callers want the `Vec<AuthorRef>` for the API response; the
|
||||
/// crawler doesn't need it and stays inside its own transaction.
|
||||
pub async fn set_for_manga(
|
||||
conn: &mut PgConnection,
|
||||
manga_id: Uuid,
|
||||
|
||||
Reference in New Issue
Block a user