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
Production-grade media metadata backend per docs/aurora-core-spec.md: Aurora-owned UUIDv7 identity system, normalized movie/TV/people/credits schema, provider abstraction with a TMDb adapter, an idempotent async ingestion pipeline (normalize -> match -> upsert -> provenance), a Postgres FTS/trigram search layer, a stateless FastAPI v1 API with Redis caching/rate-limiting, arq workers, dev/prod Docker Compose topologies, unit + integration + load tests, CI, and architecture/ database/API/ERD documentation. Co-Authored-By: Claude Sonnet 5 <[email protected]>
50 lines
1.9 KiB
Python
50 lines
1.9 KiB
Python
"""Search service: runs a `SearchProvider` and hydrates matches into full
|
|
response summaries via the entity services. API clients never see the
|
|
underlying search engine (section 16)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.schemas.search import SearchResultsOut
|
|
from app.services.collection_service import build_collection_summaries
|
|
from app.services.company_service import build_company_summaries
|
|
from app.services.movie_service import build_movie_summaries
|
|
from app.services.person_service import build_person_summaries
|
|
from app.services.search.base import SearchProvider
|
|
from app.services.tv_service import build_series_summaries
|
|
|
|
|
|
class SearchService:
|
|
def __init__(self, provider: SearchProvider) -> None:
|
|
self._provider = provider
|
|
|
|
async def search(
|
|
self, session: AsyncSession, query: str, *, limit_per_type: int = 10
|
|
) -> SearchResultsOut:
|
|
query = query.strip()
|
|
if not query:
|
|
return SearchResultsOut(query=query)
|
|
|
|
results = await self._provider.search(session, query, limit_per_type=limit_per_type)
|
|
|
|
movies = await build_movie_summaries(session, [m.entity_id for m in results.movies])
|
|
series = await build_series_summaries(session, [s.entity_id for s in results.series])
|
|
people = await build_person_summaries(session, [p.entity_id for p in results.people])
|
|
collections = await build_collection_summaries(
|
|
session, [c.entity_id for c in results.collections]
|
|
)
|
|
companies = await build_company_summaries(
|
|
session, [c.entity_id for c in results.companies]
|
|
)
|
|
|
|
return SearchResultsOut(
|
|
query=query,
|
|
movies=movies,
|
|
series=series,
|
|
people=people,
|
|
collections=collections,
|
|
companies=companies,
|
|
total_results=len(movies) + len(series) + len(people) + len(collections) + len(companies),
|
|
)
|