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