fix(parcels): SAVEPOINT around velocity → не abort outer tx (analyze 500 fix) #154
1 changed files with 7 additions and 3 deletions
|
|
@ -1808,11 +1808,15 @@ def analyze_parcel(
|
|||
pipeline_24mo = _aggregate_pipeline(pipeline_rows)
|
||||
|
||||
# D2 (#34): velocity-score — темп продаж конкурентов вокруг участка.
|
||||
# SAVEPOINT защищает outer transaction если velocity SQL падает —
|
||||
# иначе следующие queries (_geotech_risk и пр.) крашатся
|
||||
# с InFailedSqlTransaction.
|
||||
velocity_data: dict[str, Any] | None = None
|
||||
try:
|
||||
v_result = compute_velocity(db, parcel_geom_wkt=geom_wkt, radius_km=3.0)
|
||||
if v_result is not None:
|
||||
velocity_data = v_result.as_dict()
|
||||
with db.begin_nested():
|
||||
v_result = compute_velocity(db, parcel_geom_wkt=geom_wkt, radius_km=3.0)
|
||||
if v_result is not None:
|
||||
velocity_data = v_result.as_dict()
|
||||
except Exception as _ve:
|
||||
logger.warning("velocity compute failed for %s: %s", cad_num, _ve)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue