Files
Showy/react_frontend/src/api/maintenance.ts
T
X4Lo a9ff2d089a Store full TMDB data, add rate limiting and stale-entry refresh
Backend
- Route all TMDB requests through a rate limiter (20 req/s, 8 concurrent)
  with 429/5xx retries; stop logging the API key
- Fetch external ids, certification, keywords, videos, watch providers and
  alternative titles in the entry details request
- Shared entry mapper used by create, refresh, season refresh and importer
- New columns on entries, ids, ratings, seasons, episodes and people, with
  an idempotent startup migration (adds missing columns, widens types)
- Fix TV IMDb ids, network country/logo, episode tmdb_id on refresh, and
  genre/network removal on refresh
- Add stale-entries maintenance job (count, start, cancel) and live
  recommendations endpoint

Frontend
- Entry page: certification, tagline, creators, in-app trailer, vote count,
  TV/movie details, network logos, external links, keywords, where to
  watch, and recommendations
- Episode page: directors, writers and guest stars
- Settings: TMDB refresh card with live progress
2026-11-05 11:39:15 +00:00

131 lines
3.2 KiB
TypeScript

import { api } from "@/lib/api";
export interface OrphanResult {
posters: number;
logos: number;
backdrops: number;
stills: number;
}
export interface OrphanPeopleResult {
count: number;
}
export interface StaleRefreshJob {
running: boolean;
hours?: number;
total?: number;
done?: number;
succeeded?: number;
failed?: { id: number; title: string; error: string }[];
current?: { id: number; title: string } | null;
cancelRequested?: boolean;
startedAt?: string;
finishedAt?: string | null;
}
export interface StaleEntriesResult {
count: number;
hours: number;
job: StaleRefreshJob;
}
export const maintenanceApi = {
getStaleEntries: (hours = 24) =>
api
.get<StaleEntriesResult>("/maintenance/stale-entries", {
params: { hours },
})
.then((r) => r.data),
// 409 means a job is already running; its status is returned either way
startStaleRefresh: (hours = 24) =>
api
.post<StaleRefreshJob>("/maintenance/stale-entries/refresh", null, {
params: { hours },
validateStatus: (s) => s === 202 || s === 409,
})
.then((r) => r.data),
cancelStaleRefresh: () =>
api
.delete<StaleRefreshJob>("/maintenance/stale-entries/refresh")
.then((r) => r.data),
scanOrphanFiles: () =>
api.get<OrphanResult>("/maintenance/orphan-files").then((r) => r.data),
deleteOrphanFiles: () =>
api.delete<OrphanResult>("/maintenance/orphan-files").then((r) => r.data),
scanOrphanMediaRecords: () =>
api
.get<OrphanResult>("/maintenance/orphan-media-records")
.then((r) => r.data),
deleteOrphanMediaRecords: () =>
api
.delete<OrphanResult>("/maintenance/orphan-media-records")
.then((r) => r.data),
scanOrphanPeople: () =>
api
.get<OrphanPeopleResult>("/maintenance/orphan-people")
.then((r) => r.data),
deleteOrphanPeople: () =>
api
.delete<OrphanPeopleResult>("/maintenance/orphan-people")
.then((r) => r.data),
scanMissingDirectors: () =>
api
.get<{ count: number; fixed: number }>("/maintenance/missing-directors")
.then((r) => r.data),
fixMissingDirectors: () =>
api
.post<{ count: number; fixed: number }>("/maintenance/missing-directors")
.then((r) => r.data),
scanDuplicateCredits: () =>
api
.get<{
groups: number;
duplicates: number;
deleted: number;
}>("/maintenance/duplicate-credits")
.then((r) => r.data),
cleanDuplicateCredits: () =>
api
.delete<{
groups: number;
duplicates: number;
deleted: number;
}>("/maintenance/duplicate-credits")
.then((r) => r.data),
autoFixWatchStatuses: () =>
api
.post<{
completed: number;
watching: number;
planToWatch: number;
}>("/maintenance/auto-fix-watch-statuses")
.then((r) => r.data),
scanImpossibleSeenDates: () =>
api
.get<{ count: number }>("/maintenance/impossible-seen-dates")
.then((r) => r.data),
fixImpossibleSeenDates: () =>
api
.post<{
count: number;
added: number;
}>("/maintenance/impossible-seen-dates")
.then((r) => r.data),
};