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
Keywords were ingested and shown read-only on detail pages, but had no
directory (GET /keywords) or filter param -- the same gap genres had
before today. Mirrors the genre browse pattern exactly: repository,
service, route, plus a `keyword` filter on GET /movies and GET /series.
Alternate/translated titles ("Also Known As") were normalized down to
bare title strings and never written to MovieAlternateTitle/
SeriesAlternateTitle at all. Normalizer now captures country_code + type
per TMDb's actual shape; ingestion writes them; movie/series detail now
expose an alternate_titles list.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
"""Assembles Keyword API responses from repository data.
|
|
|
|
Mirrors genre_service.py exactly: keywords have no detail page of their own
|
|
-- they only appear embedded in movie/series responses and as entries in
|
|
this directory listing, which exists so a client can resolve the Aurora
|
|
keyword ids that GET /movies and GET /series accept as a filter."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.core.ids import aurora_id
|
|
from app.repositories import keyword_repository
|
|
from app.schemas.common import KeywordListOut, KeywordOut
|
|
|
|
|
|
async def list_keywords(session: AsyncSession, *, page: int, page_size: int) -> KeywordListOut:
|
|
keywords, total = await keyword_repository.list_keywords(
|
|
session, limit=page_size, offset=(page - 1) * page_size
|
|
)
|
|
results = [KeywordOut(id=aurora_id("keyword", str(k.id)), name=k.name) for k in keywords]
|
|
total_pages = (total + page_size - 1) // page_size if total else 0
|
|
|
|
return KeywordListOut(
|
|
page=page, page_size=page_size, total_results=total, total_pages=total_pages, results=results
|
|
)
|