feat: manga metadata with status, authors, genres, tags, and search filters (0.15.0)
Adds first-class manga metadata across the stack: - **Status** (ongoing / completed), **alternative titles**, normalized **multi-author** support, **curated genres** (13 seeded), and **free-form user tags** (case-insensitive, globally shared). Each is modelled as its own table joined to mangas; `mangas.author` is backfilled into `authors` + `manga_authors` and dropped. - New endpoints: `PATCH /v1/mangas/:id` (three-state `description`), `POST/DELETE /v1/mangas/:id/tags[/:tag_id]`, `GET /v1/genres`, `GET /v1/tags?search=`. - `GET /v1/mangas` now returns `MangaCard` (with authors + genres batched in) and supports `?status=`, `?author_id=`, `?genre_id=`, `?tag_id=` filters — AND across facets, with empty-array no-op semantics for the unnest primitive. - `GET /v1/mangas/:id` returns the enriched `MangaDetail` with tags. - Frontend: reusable `Chip` component; manga detail page renders authors as chips linking to `/authors/:id` (Phase 2), a status badge, alt titles, genres, and tags with inline add/remove (only the attacher sees remove); upload form supports multi-author / multi-genre / alt titles / status; search page gets a collapsible URL-synced filter panel with keyboard-navigable tag autocomplete. - 126 backend tests (incl. AND-across-facets primitive, case-insens author/tag de-dup, transactional create rollback, PATCH semantics for missing / null / set on description); 72 frontend tests + svelte-check clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -158,7 +158,11 @@ async fn create_then_list_roundtrip(pool: PgPool) {
|
||||
"/api/v1/mangas",
|
||||
MultipartBuilder::new().add_json(
|
||||
"metadata",
|
||||
json!({ "title": "Berserk", "author": "Kentaro Miura", "description": null }),
|
||||
json!({
|
||||
"title": "Berserk",
|
||||
"authors": ["Kentaro Miura"],
|
||||
"description": null,
|
||||
}),
|
||||
),
|
||||
&cookie,
|
||||
))
|
||||
@@ -167,14 +171,23 @@ async fn create_then_list_roundtrip(pool: PgPool) {
|
||||
assert_eq!(created.status(), StatusCode::CREATED);
|
||||
let body = common::body_json(created).await;
|
||||
assert_eq!(body["title"], "Berserk");
|
||||
assert_eq!(body["author"], "Kentaro Miura");
|
||||
let authors = body["authors"].as_array().unwrap();
|
||||
assert_eq!(authors.len(), 1);
|
||||
assert_eq!(authors[0]["name"], "Kentaro Miura");
|
||||
assert!(body["id"].as_str().is_some());
|
||||
// Status defaults to ongoing; tags and genres start empty.
|
||||
assert_eq!(body["status"], "ongoing");
|
||||
assert_eq!(body["genres"], json!([]));
|
||||
assert_eq!(body["tags"], json!([]));
|
||||
|
||||
let listed = h.app.oneshot(common::get("/api/v1/mangas")).await.unwrap();
|
||||
let listed_body = common::body_json(listed).await;
|
||||
let items = listed_body["items"].as_array().unwrap();
|
||||
assert_eq!(items.len(), 1);
|
||||
assert_eq!(items[0]["title"], "Berserk");
|
||||
// List endpoint returns the card shape: authors + genres included.
|
||||
let authors = items[0]["authors"].as_array().unwrap();
|
||||
assert_eq!(authors[0]["name"], "Kentaro Miura");
|
||||
}
|
||||
|
||||
#[sqlx::test(migrations = "./migrations")]
|
||||
@@ -193,13 +206,15 @@ async fn search_filters_by_title_and_author(pool: PgPool) {
|
||||
.oneshot(common::post_multipart_with_cookie(
|
||||
"/api/v1/mangas",
|
||||
MultipartBuilder::new()
|
||||
.add_json("metadata", json!({ "title": title, "author": author })),
|
||||
.add_json("metadata", json!({ "title": title, "authors": [author] })),
|
||||
&cookie,
|
||||
))
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// Searching by author name still works — the list query joins
|
||||
// authors so 'miura' resolves through the manga_authors table.
|
||||
let resp = h
|
||||
.app
|
||||
.clone()
|
||||
|
||||
Reference in New Issue
Block a user