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
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:
co-authored by
Claude Sonnet 5
parent
ec6b5bdd7d
commit
b4d1e8f755
@@ -25,6 +25,7 @@ from app.repositories.provider_repository import (
|
||||
mark_job_running,
|
||||
mark_job_succeeded,
|
||||
)
|
||||
from app.repositories.tv_repository import get_seasons_for_series
|
||||
from app.services.ingestion.movie_ingestion import ingest_movie
|
||||
from app.services.ingestion.person_ingestion import ingest_person
|
||||
from app.services.ingestion.series_ingestion import ingest_season, ingest_series
|
||||
@@ -138,3 +139,14 @@ async def run_season_ingestion(
|
||||
session, provider, series_external_id, season_number, ingestion_job_id=job_id
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def get_series_season_numbers(series_id: uuid.UUID) -> list[int]:
|
||||
"""All season numbers a just-ingested series has, for cascading into
|
||||
per-season ingestion jobs (see `app/workers/tasks.py:ingest_series_task`,
|
||||
`include_seasons`). A short-lived session of its own since this runs
|
||||
after `run_series_ingestion`'s own session has already closed."""
|
||||
|
||||
async with session_scope() as session:
|
||||
seasons = await get_seasons_for_series(session, series_id)
|
||||
return [season.season_number for season in seasons]
|
||||
|
||||
Reference in New Issue
Block a user