mirror of
https://github.com/migatu/astrololo.git
synced 2026-07-14 13:34:38 +00:00
3195d9b003
Strona główna "/" = formularz podstawowych danych momentu (data, godzina, strefa, opcjonalnie lokalizacja) → tabela policzonych pozycji w formie human-readable (znak, pozycja w znaku, absolutna, kierunek, prędkość). Woła logic /chart/positions; przelicza czas lokalny + offset na UTC. Przycisk "Tu i teraz" uzupełnia bieżącą datę/godzinę i strefę przeglądarki. Retrogradacja wyróżniona w tabeli. Wyszukiwarkę sygnifikatorów przeniesiono pod "/significants" -> /significators, dodano nawigację (base.html). Czytelny komunikat, gdy logika nie ma jeszcze endpointu silnika. Zweryfikowano end-to-end: formularz → przeliczenie UTC → render tabeli (przez stub kontraktu /chart/positions). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""Klient HTTP do warstwy logicznej.
|
|
|
|
Jedyny punkt styku prezentacji w dół. Przekazuje dane z formularza i odbiera
|
|
opracowane wyniki. Prezentacja nie sięga bezpośrednio do bazy ani do silnika.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
import httpx
|
|
|
|
from app.config import settings
|
|
|
|
|
|
class LogicClient:
|
|
def __init__(self, base_url: str | None = None) -> None:
|
|
self.base_url = (base_url or settings.logic_url).rstrip("/")
|
|
|
|
def query(self, query: str, field: str, exact: bool, limit: int) -> dict[str, Any]:
|
|
payload = {"query": query, "field": field, "exact": exact, "limit": limit}
|
|
with httpx.Client(timeout=settings.http_timeout) as client:
|
|
r = client.post(f"{self.base_url}/api/query", json=payload)
|
|
r.raise_for_status()
|
|
return r.json()
|
|
|
|
def positions(
|
|
self, when_utc_iso: str, lat: float, lon: float, objects: list[str] | None = None
|
|
) -> dict[str, Any]:
|
|
"""Pozycje obiektów dla danego momentu — woła logic /chart/positions."""
|
|
payload = {"when_utc": when_utc_iso, "lat": lat, "lon": lon, "objects": objects}
|
|
with httpx.Client(timeout=settings.http_timeout) as client:
|
|
r = client.post(f"{self.base_url}/chart/positions", json=payload)
|
|
r.raise_for_status()
|
|
return r.json()
|