Add opt-in season cascade to series ingestion
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / unit-tests (push) Canceled after 0s
CI / integration-tests (push) Canceled after 0s
CI / container-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s

Ingesting a series only ever produced season stubs -- getting actual
episodes meant calling POST /admin/ingest/season once per season by
hand, which is exactly what manual end-to-end testing kept requiring
for every multi-season show.

POST /api/v1/admin/ingest/series now takes include_seasons (default
false, since a show can have dozens of seasons and that's dozens of
TMDb calls fired from one request). When true, ingest_series_task
fans out one ingest_season job per season once the series succeeds,
using arq's own ctx['redis'] connection for the job (the same pattern
arq's docs recommend for job chaining) rather than a second unrelated
connection. Each fanned-out season job still goes through
get_or_create_ingestion_job, so re-running a cascaded series ingestion
reuses the same season job rows instead of creating duplicates.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
NixReaper
2026-09-05 02:03:25 -05:00
co-authored by Claude Sonnet 5
parent ec6b5bdd7d
commit b4d1e8f755
6 changed files with 148 additions and 6 deletions
+7 -1
View File
@@ -36,6 +36,12 @@ class IngestPersonRequest(BaseModel):
class IngestSeriesRequest(BaseModel):
tmdb_id: str
# When true, ingest_series_task also enqueues an ingest_season job for
# every season the series has, once the series itself finishes.
# Defaults to false: a show can have dozens of seasons, and cascading
# automatically means dozens of TMDb calls fired off from one request —
# opt in rather than surprise the caller with that.
include_seasons: bool = False
class IngestSeasonRequest(BaseModel):
@@ -120,7 +126,7 @@ async def enqueue_series_ingestion(
entity_type="series",
external_id=body.tmdb_id,
task_name="ingest_series_task",
task_args=(body.tmdb_id,),
task_args=(body.tmdb_id, body.include_seasons),
)