feat: synastria — aspekty między dwoma horoskopami (PRE-04)
Testy / Testy warstwy logicznej (silnik) (pull_request) Successful in 10m32s
Testy / Testy warstwy prezentacji (dostęp do baz) (pull_request) Successful in 9m28s
Testy / Build obrazu silnika B (swisseph) (pull_request) Successful in 11s
Testy / Kontrola składni wszystkich warstw (pull_request) Successful in 9s
build / build (push) Successful in 25s
Testy / Testy warstwy logicznej (silnik) (push) Successful in 11m18s
Testy / Kontrola składni wszystkich warstw (push) Successful in 31s
Testy / Build obrazu silnika B (swisseph) (push) Failing after 13m6s
Testy / Testy warstwy prezentacji (dostęp do baz) (push) Failing after 13m25s
Testy / Testy warstwy logicznej (silnik) (pull_request) Successful in 10m32s
Testy / Testy warstwy prezentacji (dostęp do baz) (pull_request) Successful in 9m28s
Testy / Build obrazu silnika B (swisseph) (pull_request) Successful in 11s
Testy / Kontrola składni wszystkich warstw (pull_request) Successful in 9s
build / build (push) Successful in 25s
Testy / Testy warstwy logicznej (silnik) (push) Successful in 11m18s
Testy / Kontrola składni wszystkich warstw (push) Successful in 31s
Testy / Build obrazu silnika B (swisseph) (push) Failing after 13m6s
Testy / Testy warstwy prezentacji (dostęp do baz) (push) Failing after 13m25s
Pierwsza technika relacyjna z pełnym UI (Returns były już w kalendarzu od LOG-12). Dwie osoby → aspekty MIĘDZY ich horoskopami (planeta osoby A do planety osoby B). Silnik: `find_cross_aspects(a, b, orb, luminary_bonus, minor)` — każdy obiekt A × każdy obiekt B. `obj1` = osoba A, `obj2` = osoba B. Statyczne (dwa natale, brak wspólnego czasu) → bez applying/separating. Par sztywnych (NN/SN) NIE wycinamy — między dwiema osobami to realny aspekt, nie artefakt definicji. Wspólny matcher `_first_aspect` (z find_aspects), więc orb/bonus/aspekty poboczne działają tak samo. Endpoint `POST /chart/synastry` (dwie osoby + zodiak + ustawienia aspektów) → pozycje obu + siatka aspektów z glifami. Prezentacja: zakładka „Synastria", formularz dwóch osób (pętla po a_/b_), tabela aspektów A · aspekt · B · orb. Weryfikacja na żywym API: 13+13 obiektów, 63 aspekty synastryczne z poprawnymi glifami i bonusem świateł (A.Sun ☌ B.Venus przy orbie 8.67 = 8+2). Testy: logika +4 (cross-aspekty, kolejność A/B, brak filtra par sztywnych, brak applying), prezentacja +7 (trasa, formularz dwóch osób, klient, tabela). Logika 277, prezentacja 228. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit was merged in pull request #51.
This commit is contained in:
@@ -78,6 +78,18 @@ class LogicClient:
|
||||
timeout = max(settings.http_timeout, 60.0) if (stations or tables) else settings.http_timeout
|
||||
return self._post("/chart/positions", payload, timeout)
|
||||
|
||||
def synastry(
|
||||
self, person_a: dict, person_b: dict, zodiac: str = "tropical",
|
||||
aspect_orb: float = 8.0, aspect_luminary_bonus: float = 2.0, aspect_minor: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
"""Synastria dwóch osób (PRE-04) — aspekty między horoskopami."""
|
||||
payload = {
|
||||
"person_a": person_a, "person_b": person_b, "zodiac": zodiac,
|
||||
"aspect_orb": aspect_orb, "aspect_luminary_bonus": aspect_luminary_bonus,
|
||||
"aspect_minor": aspect_minor,
|
||||
}
|
||||
return self._post("/chart/synastry", payload, settings.http_timeout)
|
||||
|
||||
def report(
|
||||
self, when_utc_iso: str, lat: float, lon: float, limit: int = 5000, group: bool = False
|
||||
) -> dict[str, Any]:
|
||||
|
||||
@@ -277,6 +277,49 @@ def compile_pdf(payload: dict):
|
||||
headers={"Content-Disposition": 'attachment; filename="raport.pdf"'})
|
||||
|
||||
|
||||
# ---------------- Synastria (technika relacyjna) ----------------
|
||||
@app.get("/synastry", response_class=HTMLResponse)
|
||||
def synastry_form(request: Request):
|
||||
# domyślne liczby, żeby pola number nie były puste (puste → błąd przy wysyłce)
|
||||
form = {"a_tz_offset": 0, "a_lat": 0, "a_lon": 0, "b_tz_offset": 0, "b_lat": 0, "b_lon": 0,
|
||||
"aspect_orb": 8, "aspect_luminary_bonus": 2}
|
||||
return templates.TemplateResponse(request, "synastry.html", {"result": None, "form": form})
|
||||
|
||||
|
||||
@app.post("/synastry", response_class=HTMLResponse)
|
||||
def synastry_run(
|
||||
request: Request,
|
||||
a_person: str = Form(""), a_date: str = Form(...), a_time: str = Form(...),
|
||||
a_tz_offset: float = Form(0.0), a_lat: float = Form(0.0), a_lon: float = Form(0.0),
|
||||
b_person: str = Form(""), b_date: str = Form(...), b_time: str = Form(...),
|
||||
b_tz_offset: float = Form(0.0), b_lat: float = Form(0.0), b_lon: float = Form(0.0),
|
||||
zodiac: str = Form("tropical"),
|
||||
aspect_orb: float = Form(8.0), aspect_luminary_bonus: float = Form(2.0),
|
||||
aspect_minor: bool = Form(False),
|
||||
):
|
||||
"""Synastria (PRE-04): dwie osoby → aspekty między ich horoskopami."""
|
||||
form = {"a_person": a_person, "a_date": a_date, "a_time": a_time, "a_tz_offset": a_tz_offset,
|
||||
"a_lat": a_lat, "a_lon": a_lon, "b_person": b_person, "b_date": b_date,
|
||||
"b_time": b_time, "b_tz_offset": b_tz_offset, "b_lat": b_lat, "b_lon": b_lon,
|
||||
"zodiac": zodiac, "aspect_orb": aspect_orb,
|
||||
"aspect_luminary_bonus": aspect_luminary_bonus, "aspect_minor": aspect_minor}
|
||||
ctx: dict = {"form": form, "result": None, "error": None}
|
||||
try:
|
||||
iso_a, _ = _build_utc(a_date, a_time, a_tz_offset)
|
||||
iso_b, _ = _build_utc(b_date, b_time, b_tz_offset)
|
||||
ctx["result"] = logic.synastry(
|
||||
{"when_utc": iso_a, "lat": a_lat, "lon": a_lon},
|
||||
{"when_utc": iso_b, "lat": b_lat, "lon": b_lon},
|
||||
zodiac=zodiac, aspect_orb=aspect_orb,
|
||||
aspect_luminary_bonus=aspect_luminary_bonus, aspect_minor=aspect_minor,
|
||||
)
|
||||
except httpx.HTTPError as e:
|
||||
ctx["error"] = _logic_error(e)
|
||||
except ValueError as e:
|
||||
ctx["error"] = f"Niepoprawne dane wejściowe: {e}"
|
||||
return templates.TemplateResponse(request, "synastry.html", ctx)
|
||||
|
||||
|
||||
# ---------------- Sygnifikatory (wyszukiwarka w bazach) ----------------
|
||||
@app.get("/significators", response_class=HTMLResponse)
|
||||
def significators_form(request: Request):
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<a href="/" class="{% block nav_chart %}{% endblock %}">Horoskop</a>
|
||||
<a href="/interpret" class="{% block nav_interp %}{% endblock %}">Interpretacje</a>
|
||||
<a href="/timeline" class="{% block nav_timeline %}{% endblock %}">Kalendarz</a>
|
||||
<a href="/synastry" class="{% block nav_synastry %}{% endblock %}">Synastria</a>
|
||||
<a href="/significators" class="{% block nav_sig %}{% endblock %}">Sygnifikatory</a>
|
||||
<a href="/compile" class="{% block nav_compile %}{% endblock %}">Skompiluj</a>
|
||||
</nav>
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Synastria{% endblock %}
|
||||
{% block nav_synastry %}active{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<p class="sub">Dwie osoby → aspekty <strong>między</strong> ich horoskopami (planeta jednej osoby do planety drugiej). Bez interpretacji z bazy — sama siatka aspektów.</p>
|
||||
|
||||
<form method="post" action="/synastry">
|
||||
<div class="grid">
|
||||
{% for p in [{'k': 'a', 'label': 'Osoba A'}, {'k': 'b', 'label': 'Osoba B'}] %}
|
||||
<fieldset style="flex:1; min-width:16rem; border:1px solid var(--line); border-radius:12px; padding:1rem;">
|
||||
<legend class="muted small">{{ p.label }}</legend>
|
||||
<label>Imię
|
||||
<input type="text" name="{{ p.k }}_person" autocomplete="name" value="{{ form[p.k ~ '_person'] or '' }}">
|
||||
</label>
|
||||
<div class="grid">
|
||||
<label>Data <input type="date" name="{{ p.k }}_date" value="{{ form[p.k ~ '_date'] or '' }}" required></label>
|
||||
<label>Godzina <input type="time" name="{{ p.k }}_time" value="{{ form[p.k ~ '_time'] or '' }}" required></label>
|
||||
</div>
|
||||
<div class="grid">
|
||||
<label title="Przesunięcie względem GMT, krok 15 min">Offset GMT (h)
|
||||
<input type="number" name="{{ p.k }}_tz_offset" step="0.25" min="-12" max="14"
|
||||
value="{{ form[p.k ~ '_tz_offset'] if form[p.k ~ '_tz_offset'] is not none else 0 }}"></label>
|
||||
<label>Szer. (lat) <input type="number" name="{{ p.k }}_lat" step="0.0001" value="{{ form[p.k ~ '_lat'] if form[p.k ~ '_lat'] is not none else 0 }}"></label>
|
||||
<label>Dług. (lon) <input type="number" name="{{ p.k }}_lon" step="0.0001" value="{{ form[p.k ~ '_lon'] if form[p.k ~ '_lon'] is not none else 0 }}"></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="opts" title="Wspólne dla obu osób. Orb i aspekty poboczne jak przy horoskopie (PRE-06).">
|
||||
<label>Zodiak
|
||||
<select name="zodiac">
|
||||
{% set zd = form.zodiac or 'tropical' %}
|
||||
<option value="tropical" {{ 'selected' if zd == 'tropical' else '' }}>Tropikalny</option>
|
||||
<option value="sidereal_lahiri" {{ 'selected' if zd == 'sidereal_lahiri' else '' }}>Syderyczny (Lahiri)</option>
|
||||
<option value="draconic" {{ 'selected' if zd == 'draconic' else '' }}>Draconic</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>Orb aspektów (°) <input type="number" name="aspect_orb" step="0.5" min="1" max="15" value="{{ form.aspect_orb if form.aspect_orb is not none else 8 }}"></label>
|
||||
<label>Bonus świateł (°) <input type="number" name="aspect_luminary_bonus" step="0.5" min="0" max="5" value="{{ form.aspect_luminary_bonus if form.aspect_luminary_bonus is not none else 2 }}"></label>
|
||||
<label><input type="checkbox" name="aspect_minor" value="true" {{ 'checked' if form.aspect_minor else '' }}> aspekty poboczne (30/45/150°)</label>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button type="submit">Policz synastrię</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% if error %}<div class="error">{{ error }}</div>{% endif %}
|
||||
|
||||
{% if result %}
|
||||
{% set an = form.a_person or 'Osoba A' %}
|
||||
{% set bn = form.b_person or 'Osoba B' %}
|
||||
<div class="meta">Aspekty synastryczne ({{ result.aspects | length }}) · <strong>{{ an }}</strong> ↔ <strong>{{ bn }}</strong> · silnik {{ result.engine }}</div>
|
||||
{% if result.aspects %}
|
||||
<table class="angles">
|
||||
<thead><tr><th>{{ an }}</th><th>Aspekt</th><th>{{ bn }}</th><th>Orb</th></tr></thead>
|
||||
<tbody>
|
||||
{% for a in result.aspects %}
|
||||
<tr>
|
||||
<td>{{ a.obj1 }}</td>
|
||||
<td>{% if a.glyph %}<span class="glyph">{{ a.glyph }}</span> {% endif %}{{ a.aspect }}</td>
|
||||
<td>{{ a.obj2 }}</td>
|
||||
<td class="mono">{{ '%.2f'|format(a.orb) }}°</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p class="muted">Brak aspektów w zadanym orbie. Spróbuj szerszego orbu albo aspektów pobocznych.</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -28,8 +28,8 @@ def test_both_forms_have_aspect_settings():
|
||||
|
||||
|
||||
def test_handlers_accept_and_pass_aspect_settings():
|
||||
# oba wywołania logic.positions (chart + compile) dostają orb
|
||||
assert MAIN.count("aspect_orb=aspect_orb") == 2
|
||||
# co najmniej Horoskop i Skompiluj przekazują orb do logiki (synastria też — 3)
|
||||
assert MAIN.count("aspect_orb=aspect_orb") >= 2
|
||||
assert "aspect_minor: bool = Form(False)" in MAIN
|
||||
|
||||
|
||||
|
||||
@@ -50,10 +50,11 @@ def test_person_value_survives_submit(name):
|
||||
|
||||
|
||||
def test_handlers_accept_and_echo_person():
|
||||
"""Każdy handler renderujący formularz przyjmuje `person` i wkłada go
|
||||
"""Każdy handler renderujący WSPÓLNY formularz przyjmuje `person` i wkłada go
|
||||
z powrotem do `form` — inaczej imię znikałoby po przeliczeniu.
|
||||
Cztery: Horoskop, Interpretacje, Kalendarz, Skompiluj (PRE-23)."""
|
||||
assert MAIN_PY.count("person: str = Form") == 4
|
||||
Cztery: Horoskop, Interpretacje, Kalendarz, Skompiluj (PRE-23). Synastria ma
|
||||
własne `a_person`/`b_person` (dwie osoby), więc echo `"person": person` = 4."""
|
||||
assert MAIN_PY.count(" person: str = Form") == 4 # spacja z przodu wyklucza a_/b_person
|
||||
assert MAIN_PY.count('"person": person') == 4
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
"""Synastria — technika relacyjna (PRE-04)."""
|
||||
import pathlib
|
||||
|
||||
APP = pathlib.Path(__file__).resolve().parents[1] / "app"
|
||||
TPL = (APP / "templates" / "synastry.html").read_text(encoding="utf-8")
|
||||
BASE = (APP / "templates" / "base.html").read_text(encoding="utf-8")
|
||||
MAIN = (APP / "main.py").read_text(encoding="utf-8")
|
||||
CLIENT = (APP / "clients" / "logic_client.py").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def _client():
|
||||
import os
|
||||
|
||||
os.environ.pop("APP_PASSWORD", None)
|
||||
from starlette.testclient import TestClient
|
||||
|
||||
from app.main import app
|
||||
|
||||
return TestClient(app)
|
||||
|
||||
|
||||
def test_tab_is_in_the_menu():
|
||||
assert 'href="/synastry"' in BASE and "Synastria" in BASE
|
||||
|
||||
|
||||
def test_routes_exist():
|
||||
assert '@app.get("/synastry"' in MAIN and '@app.post("/synastry"' in MAIN
|
||||
|
||||
|
||||
def test_get_renders_two_person_form():
|
||||
r = _client().get("/synastry")
|
||||
assert r.status_code == 200
|
||||
# dwie osoby: pola z prefiksami a_ i b_
|
||||
for pfx in ("a_", "b_"):
|
||||
assert f'name="{pfx}date"' in r.text and f'name="{pfx}time"' in r.text
|
||||
|
||||
|
||||
def test_form_has_both_people_and_shared_aspect_settings():
|
||||
"""Pola dwóch osób generuje pętla — sprawdzamy WYRENDEROWANY formularz."""
|
||||
html = _client().get("/synastry").text
|
||||
for pfx in ("a_", "b_"):
|
||||
assert f'name="{pfx}person"' in html
|
||||
assert f'name="{pfx}lat"' in html
|
||||
assert 'name="aspect_orb"' in html and 'name="aspect_minor"' in html
|
||||
|
||||
|
||||
def test_handler_calls_synastry_with_both_moments():
|
||||
assert "logic.synastry(" in MAIN
|
||||
assert '"when_utc": iso_a' in MAIN and '"when_utc": iso_b' in MAIN
|
||||
|
||||
|
||||
def test_client_posts_to_synastry_endpoint():
|
||||
assert 'self._post("/chart/synastry"' in CLIENT
|
||||
assert '"person_a": person_a' in CLIENT and '"person_b": person_b' in CLIENT
|
||||
|
||||
|
||||
def test_result_table_shows_cross_aspects():
|
||||
"""Wynik: kolumny osoba A · aspekt · osoba B · orb."""
|
||||
assert "Aspekty synastryczne" in TPL
|
||||
assert "a.obj1" in TPL and "a.obj2" in TPL and "a.glyph" in TPL
|
||||
Reference in New Issue
Block a user