| from __future__ import annotations | |
| from fastapi import APIRouter, Depends | |
| from sqlalchemy import func, select | |
| from sqlalchemy.orm import Session | |
| from ..config import settings | |
| from ..db import get_db | |
| from ..models import UnknownDog | |
| from ..models.base import UnknownDogStatus | |
| from .shelters import nearby_shelters | |
| router = APIRouter(tags=["geo"]) | |
| def get_nearby_shelters(zip: str | None = None) -> dict: | |
| return {"zip": zip, "shelters": nearby_shelters(zip)} | |
| def healthz() -> dict: | |
| return {"status": "ok"} | |
| def public_config(db: Session = Depends(get_db)) -> dict: | |
| """Public runtime config the frontend reads on load: which UI to render, and how many | |
| found/unclaimed dogs a photo search is compared against (the searchable haystack size).""" | |
| haystack_size = db.execute( | |
| select(func.count(UnknownDog.id)).where(UnknownDog.status == UnknownDogStatus.pending) | |
| ).scalar() | |
| return {"demo_mode": settings.demo_mode, "haystack_size": haystack_size} | |