Files
Aurora-Core/app/models/trending.py
T

36 lines
1.5 KiB
Python
Raw Normal View History

"""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"]