Add trending movies/series, refreshed on a schedule
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

Mirrors TMDb's own /trending/{movie|tv}/{day|week} ranking rather than
Aurora computing trending itself from popularity deltas -- that would
require re-syncing the entire catalog on a schedule, infeasible at any
real scale, whereas TMDb already computes this well from signals (real
view/search velocity) Aurora has no access to.

New: TrendingEntry model + migration 0003, MetadataProvider.get_trending
(concrete/optional, like aclose(), so existing test fakes don't all need
updating), refresh_trending() which actually ingests each trending item
(only ~20 per window, cheap enough to fully ingest rather than apply the
never-fabricate-a-stub rule recommendations uses), a twice-daily arq cron
job (WorkerSettings.cron_jobs, new to this codebase), a manual admin
trigger for right after a deploy, and GET /movies/trending + GET
/series/trending.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
NixReaper
2026-09-06 05:18:02 -05:00
co-authored by Claude Sonnet 5
parent 6c95e18aad
commit 4403305da6
16 changed files with 513 additions and 2 deletions
+11
View File
@@ -70,5 +70,16 @@ class MetadataProvider(ABC):
"""Search this provider's catalog for movies matching `query`. Used
to seed ingestion, not exposed directly to API clients."""
async def get_trending(self, media_type: str, time_window: str) -> list[dict[str, Any]]:
"""Fetch a ranked list of raw items (movies or series, per
`media_type`) currently trending over `time_window` ("day" |
"week"). Not every provider has a trending concept, so this is
concrete rather than abstract (like `aclose` below) — a provider
that doesn't support it simply doesn't override this, and callers
get an empty list rather than every other provider implementation
having to stub out a method that means nothing for them."""
return []
async def aclose(self) -> None:
"""Release any held resources (HTTP clients, ...). Optional."""
+7
View File
@@ -124,6 +124,13 @@ class TMDbProvider(MetadataProvider):
data = await self._get("/search/movie", {"query": query})
return data.get("results", [])
async def get_trending(self, media_type: str, time_window: str) -> list[dict[str, Any]]:
# TMDb's own endpoint shape: /trending/{movie|tv}/{day|week} -- page
# 1 only (~20 results), enough for a trending rail without pulling
# in TMDb's full multi-page trending list.
data = await self._get(f"/trending/{media_type}/{time_window}")
return data.get("results", [])
async def aclose(self) -> None:
if self._owns_client:
await self._client.aclose()