mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-22 16:46:10 -08:00
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:
41 files changed
+2230
-109
No files matched your search
@@ -1,11 +1,16 @@
|
||||
import { useCallback, useState, useEffect, useRef } from 'react';
|
||||
import { useCallback, useMemo, useState, useEffect, useRef } from 'react';
|
||||
import { getStatsClient } from './useStatsApi';
|
||||
import type { AnimeLibraryItem, StatsAnimeMergeRecommendation } from '../types/stats';
|
||||
import type { AnimeLibraryGroup, StatsAnimeMergeRecommendation } from '../types/stats';
|
||||
|
||||
const BACKGROUND_REFRESH_MS = 30_000;
|
||||
|
||||
/**
|
||||
* The library as franchise cards (`groups`) plus every entry on its own
|
||||
* (`anime`), which merging and duplicate review work on.
|
||||
*/
|
||||
export function useAnimeLibrary() {
|
||||
const [anime, setAnime] = useState<AnimeLibraryItem[]>([]);
|
||||
const [groups, setGroups] = useState<AnimeLibraryGroup[]>([]);
|
||||
const anime = useMemo(() => groups.flatMap((group) => group.parts), [groups]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [recommendations, setRecommendations] = useState<StatsAnimeMergeRecommendation[]>([]);
|
||||
@@ -29,11 +34,11 @@ export function useAnimeLibrary() {
|
||||
let cancelled = false;
|
||||
const client = getStatsClient();
|
||||
client
|
||||
.getAnimeLibrary()
|
||||
.getAnimeLibraryGroups()
|
||||
.then((data) => {
|
||||
if (!cancelled) {
|
||||
hasLoadedRef.current = true;
|
||||
setAnime(data);
|
||||
setGroups(data);
|
||||
setError(null);
|
||||
}
|
||||
})
|
||||
@@ -103,6 +108,7 @@ export function useAnimeLibrary() {
|
||||
}, []);
|
||||
|
||||
return {
|
||||
groups,
|
||||
anime,
|
||||
loading,
|
||||
error,
|
||||
|
||||
Reference in new issue
Block a user