Ensure enrichment data is always available on title pages

Cast, availability, recommendations, colors, and trailers were missing
on first load because importTitle fire-and-forgot enrichment tasks.
getTitleWithChildren now calls ensureEnriched() to backfill any missing
data before rendering — works for new imports, old titles, and shells.

Also removes the awaitEnrichment option from importTitle (redundant now)
and optimizes DB queries: reuses already-read data for existence checks,
caches fetchSeasonsFromDb result, and skips re-reads when no backfill ran.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 20:18:38 -05:00
co-authored by Claude Opus 4.6
parent be18531ea7
commit 61908778c9
2 changed files with 148 additions and 116 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ export async function POST(req: NextRequest) {
}
try {
const title = await importTitle(tmdbId, type, { awaitEnrichment: true });
const title = await importTitle(tmdbId, type);
return NextResponse.json({ id: title?.id });
} catch {
return NextResponse.json(