Add GET /companies 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

Completes the browse/discover set across all four entity types.
Companies have no popularity or date field, so unlike movies/series/
people there's no sort_by choice -- always alphabetical by name.
Filters are company_type (validated against the enum) and country
(a plain ISO 3166-1 code comparison, nothing to validate).

build_company_summary refactored to share row-to-summary logic with
the new list path, same pattern used for movies/series/people.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
NixReaper
2026-09-05 19:08:14 -05:00
co-authored by Claude Sonnet 5
parent 6aa9f0b840
commit 92b0f4e077
6 changed files with 227 additions and 12 deletions
+20 -2
View File
@@ -2,13 +2,13 @@
from __future__ import annotations
from fastapi import APIRouter, Depends
from fastapi import APIRouter, Depends, HTTPException, Query, status
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.company import CompanyDetailOut
from app.schemas.company import CompanyDetailOut, CompanyListOut
from app.services import company_service
router = APIRouter(
@@ -16,6 +16,24 @@ router = APIRouter(
)
@router.get("", response_model=CompanyListOut)
async def list_companies(
company_type: str | None = Query(
None, description="production_company, network, studio, or distributor"
),
country: str | None = Query(None, description="ISO 3166-1 alpha-2 country code, e.g. US"),
page: int = Query(1, ge=1),
page_size: int = Query(20, ge=1, le=50),
session: AsyncSession = Depends(get_db),
) -> CompanyListOut:
try:
return await company_service.list_companies(
session, company_type=company_type, country=country, page=page, page_size=page_size
)
except company_service.InvalidCompanyFilterError as exc:
raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc
@router.get("/{aurora_id}", response_model=CompanyDetailOut)
async def get_company(
aurora_id: str, session: AsyncSession = Depends(get_db)