Files
Aurora-Core/app/api/v1/collections.py
T
NixReaperandClaude Sonnet 5 f1ac072794
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
Add GET /collections browse endpoint; fix embedded collection poster_path
Completes browse/discover across all five entity types: movies, series,
people, companies, and now collections. No filter (no categorical field
like company_type exists for a collection) -- just page/page_size,
always alphabetical by name.

While adding poster_path to CollectionBriefOut for the browse listing,
found the same class of bug fixed earlier for company logo_path:
movie_service's embedded `collection` field never looked up its poster
artwork either, so it stayed null even after ingest_collection populated
one. Fixed alongside since it's the same schema field this feature was
already touching.

Also removed PageMeta from schemas/common.py -- scaffolding from early
spec work that was never actually wired into any endpoint; all five
browse endpoints shipped this session use a flat page/page_size/
total_results/total_pages shape instead.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-09-05 20:08:26 -05:00

36 lines
1.2 KiB
Python

"""Collection/franchise endpoints (section 17)."""
from __future__ import annotations
from fastapi import APIRouter, Depends, Query
from sqlalchemy.ext.asyncio import AsyncSession
from app.api.deps import not_found
from app.core.database import get_db
from app.core.security import enforce_rate_limit
from app.schemas.collection import CollectionDetailOut, CollectionListOut
from app.services import collection_service
router = APIRouter(
prefix="/collections", tags=["collections"], dependencies=[Depends(enforce_rate_limit)]
)
@router.get("", response_model=CollectionListOut)
async def list_collections(
page: int = Query(1, ge=1),
page_size: int = Query(20, ge=1, le=50),
session: AsyncSession = Depends(get_db),
) -> CollectionListOut:
return await collection_service.list_collections(session, page=page, page_size=page_size)
@router.get("/{aurora_id}", response_model=CollectionDetailOut)
async def get_collection(
aurora_id: str, session: AsyncSession = Depends(get_db)
) -> CollectionDetailOut:
try:
return await collection_service.get_collection_detail(session, aurora_id)
except collection_service.CollectionNotFoundError as exc:
raise not_found("collection", aurora_id) from exc