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]>
36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
"""Aurora's mirror of TMDb's own trending lists (section 17, additive).
|
|
|
|
TMDb already computes trending using signals Aurora has no access to
|
|
(real view/search velocity across their whole audience) — reinventing
|
|
that from Aurora's own popularity snapshots would require re-syncing the
|
|
entire catalog on a schedule, which isn't feasible at any real scale.
|
|
Instead Aurora asks TMDb what's trending right now and mirrors that
|
|
ranked list (see app/services/ingestion/trending_ingestion.py)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import uuid
|
|
|
|
from sqlalchemy import Index, Integer, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
|
|
|
|
|
class TrendingEntry(Base, UUIDPrimaryKeyMixin, TimestampMixin):
|
|
"""One row per (entity, time_window) currently on Aurora's trending
|
|
list -- replaced wholesale on each refresh, same as ReleaseDate/
|
|
WatchProviderOffering. `updated_at` doubles as "when this window was
|
|
last refreshed"."""
|
|
|
|
__tablename__ = "trending_entries"
|
|
__table_args__ = (Index("ix_trending_entries_window", "entity_type", "time_window"),)
|
|
|
|
entity_type: Mapped[str] = mapped_column(String(30), nullable=False) # "movie" | "series"
|
|
entity_id: Mapped[uuid.UUID] = mapped_column(nullable=False, index=True)
|
|
time_window: Mapped[str] = mapped_column(String(10), nullable=False) # "day" | "week"
|
|
rank: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
|
|
|
|
__all__ = ["TrendingEntry"]
|