fix(parcels): SAVEPOINT around velocity → не abort outer tx (analyze 500 fix) #154

Merged
lekss361 merged 1 commit from fix/velocity-savepoint-aborted-tx into main 2026-05-15 05:29:24 +00:00

View file

@ -1808,8 +1808,12 @@ def analyze_parcel(
pipeline_24mo = _aggregate_pipeline(pipeline_rows) pipeline_24mo = _aggregate_pipeline(pipeline_rows)
# D2 (#34): velocity-score — темп продаж конкурентов вокруг участка. # D2 (#34): velocity-score — темп продаж конкурентов вокруг участка.
# SAVEPOINT защищает outer transaction если velocity SQL падает —
# иначе следующие queries (_geotech_risk и пр.) крашатся
# с InFailedSqlTransaction.
velocity_data: dict[str, Any] | None = None velocity_data: dict[str, Any] | None = None
try: try:
with db.begin_nested():
v_result = compute_velocity(db, parcel_geom_wkt=geom_wkt, radius_km=3.0) v_result = compute_velocity(db, parcel_geom_wkt=geom_wkt, radius_km=3.0)
if v_result is not None: if v_result is not None:
velocity_data = v_result.as_dict() velocity_data = v_result.as_dict()