Add GET /people browse/discover endpoint
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
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
Extends the browse/discover pattern already built for movies/series to the fourth major entity type. No genre/year/status equivalent for people -- known_for_department is the one categorical filter that actually means something for a cast/crew list, and sort_by is just popularity (default) or name. No invalid-filter case either: unlike genre/status, known_for_department is a plain string compared directly, nothing to parse or validate. build_person_summary refactored to share row-to-summary logic with the new list path, same pattern used for movies/series/companies. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
74adcf77bc
commit
6aa9f0b840
+25
-2
@@ -2,7 +2,9 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from typing import Literal
|
||||
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from redis.asyncio import Redis
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
@@ -10,13 +12,34 @@ from app.api.deps import cached_response, not_found
|
||||
from app.core.database import get_db
|
||||
from app.core.redis import get_redis
|
||||
from app.core.security import enforce_rate_limit
|
||||
from app.schemas.person import PersonCreditsOut, PersonDetailOut
|
||||
from app.schemas.person import PersonCreditsOut, PersonDetailOut, PersonListOut
|
||||
from app.services import person_service
|
||||
from app.services.cache import build_key
|
||||
|
||||
router = APIRouter(prefix="/people", tags=["people"], dependencies=[Depends(enforce_rate_limit)])
|
||||
|
||||
|
||||
@router.get("", response_model=PersonListOut)
|
||||
async def list_people(
|
||||
known_for_department: str | None = Query(
|
||||
None, description="Exact match, e.g. Acting, Directing, Writing"
|
||||
),
|
||||
sort_by: Literal["popularity", "name"] = Query("popularity"),
|
||||
sort_dir: Literal["asc", "desc"] = Query("desc"),
|
||||
page: int = Query(1, ge=1),
|
||||
page_size: int = Query(20, ge=1, le=50),
|
||||
session: AsyncSession = Depends(get_db),
|
||||
) -> PersonListOut:
|
||||
return await person_service.list_people(
|
||||
session,
|
||||
known_for_department=known_for_department,
|
||||
sort_by=sort_by,
|
||||
sort_dir=sort_dir,
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
)
|
||||
|
||||
|
||||
@router.get("/{aurora_id}", response_model=PersonDetailOut)
|
||||
async def get_person(
|
||||
aurora_id: str,
|
||||
|
||||
Reference in New Issue
Block a user