Add GET /movies/{id}/recommendations
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

Ingestion already stored movie_recommendations edges from TMDb's
recommendations list (linking only to movies already ingested into
Aurora, per the never-fabricate-a-stub rule), but nothing exposed them.
Adds the repository lookup, service assembly, and route to read them
back in ranked order.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
NixReaper
2026-09-05 08:16:18 -05:00
co-authored by Claude Sonnet 5
parent 73488a0d80
commit 4af4ba40ef
6 changed files with 106 additions and 2 deletions
+18 -1
View File
@@ -11,7 +11,7 @@ from sqlalchemy.orm import selectinload
from app.models.company import Company, MovieCompany
from app.models.genre import Genre, MovieGenre
from app.models.keyword import Keyword, MovieKeyword
from app.models.movie import Movie
from app.models.movie import Movie, MovieRecommendation
async def get_movie_by_id(session: AsyncSession, movie_id: uuid.UUID) -> Movie | None:
@@ -59,3 +59,20 @@ async def get_movie_companies(
)
result = await session.execute(stmt)
return [(company, role) for company, role in result.all()]
async def get_movie_recommendation_ids(
session: AsyncSession, movie_id: uuid.UUID
) -> list[uuid.UUID]:
"""Aurora ids of movies TMDb recommends alongside this one, ordered by
rank (section 15) -- only ever movies already ingested into Aurora, since
`ingest_movie` (movie_ingestion.py) links these edges purely by
external-id lookup and never creates a stub for an unseen movie."""
stmt = (
select(MovieRecommendation.recommended_movie_id)
.where(MovieRecommendation.movie_id == movie_id)
.order_by(MovieRecommendation.rank.asc().nulls_last())
)
result = await session.execute(stmt)
return list(result.scalars().all())