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]>
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
"""trending
|
|
|
|
Revision ID: 0003_trending
|
|
Revises: 0002_watch_providers
|
|
Create Date: 2026-09-06
|
|
|
|
Adds trending_entries (section 17, additive): Aurora's mirror of TMDb's
|
|
own trending lists, refreshed on a schedule -- see
|
|
app/services/ingestion/trending_ingestion.py.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "0003_trending"
|
|
down_revision: str | None = "0002_watch_providers"
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"trending_entries",
|
|
sa.Column("id", sa.Uuid(), primary_key=True),
|
|
sa.Column(
|
|
"created_at",
|
|
sa.DateTime(timezone=True),
|
|
server_default=sa.text("now()"),
|
|
nullable=False,
|
|
),
|
|
sa.Column(
|
|
"updated_at",
|
|
sa.DateTime(timezone=True),
|
|
server_default=sa.text("now()"),
|
|
nullable=False,
|
|
),
|
|
sa.Column("entity_type", sa.String(30), nullable=False),
|
|
sa.Column("entity_id", sa.Uuid(), nullable=False),
|
|
sa.Column("time_window", sa.String(10), nullable=False),
|
|
sa.Column("rank", sa.Integer(), nullable=False),
|
|
)
|
|
op.create_index("ix_trending_entries_entity_id", "trending_entries", ["entity_id"])
|
|
op.create_index(
|
|
"ix_trending_entries_window", "trending_entries", ["entity_type", "time_window"]
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_trending_entries_window", table_name="trending_entries")
|
|
op.drop_index("ix_trending_entries_entity_id", table_name="trending_entries")
|
|
op.drop_table("trending_entries")
|