feat(stats): group library seasons, movies and OVAs into franchise cards

The stats library now lists each anime once. Grouping is a view over
imm_anime rows computed from a cached AniList relation graph; no rows are
merged and identity keys are unchanged.

- Schema 27: imm_anilist_media + imm_anilist_relations cache every AniList
  entry reached from the library and all its anime edges. A background
  refresher walks from owned AniList ids (depth 6, 250 fetches per run,
  7-day staleness) through the shared AniList rate limiter; a failed fetch
  leaves cached rows untouched.
- FRANCHISE_RELATION_TYPES (PREQUEL, SEQUEL, PARENT, SIDE_STORY, SUMMARY,
  COMPILATION, CONTAINS) joins entries; an entry that names the other only
  through an excluded type (a spin-off's original) vetoes the join.
- GET /api/stats/anime/groups returns cards with summed totals, the root
  entry's title, and parts in release order. Entries without cached
  relations stay single cards identical to before.
- imm_anime.group_override (NULL = AniList, 0 = on its own, positive =
  join the franchise containing that AniList id) with
  PUT /api/stats/anime/:id/group and Move to Another Anime / Show On Its
  Own / Put Back Where AniList Has It on the title page.
- SSH sync merges the override last-writer-wins on
  group_override_updated_at and skips the rebuildable relation cache.
This commit is contained in:
sudacode committed 2026-11-22 02:33:44 -08:00
1 parent 0ae70b4ab2
commit 2edf56541c
41 files changed
+2230 -109

No files matched your search

@@ -12,6 +12,8 @@ interface LibraryEntryPickerProps {
excludeAnimeIds?: number[];
/** When set, only entries of this kind are offered. */
mediaKind?: MediaKind;
/** Further narrows the entries offered. */
filter?: (entry: AnimeLibraryItem) => boolean;
initialQuery?: string;
busyAnimeId?: number | null;
error?: string | null;
@@ -23,6 +25,7 @@ export function LibraryEntryPicker({
heading,
excludeAnimeIds = [],
mediaKind,
filter,
initialQuery = '',
busyAnimeId = null,
error = null,
@@ -74,9 +77,10 @@ export function LibraryEntryPicker({
return (entries ?? [])
.filter((entry) => !excluded.has(entry.animeId))
.filter((entry) => mediaKind === undefined || shareTitleNamespace(entry.mediaKind, mediaKind))
.filter((entry) => filter === undefined || filter(entry))
.filter((entry) => !term || entry.canonicalTitle.toLowerCase().includes(term))
.sort((a, b) => b.lastWatchedMs - a.lastWatchedMs);
}, [entries, excluded, mediaKind, query]);
}, [entries, excluded, mediaKind, filter, query]);
return (
<div