fix(site-finder): SET LOCAL statement_timeout литералом — bind ломал nearby_network_zones
All checks were successful
CI Trade-In / changes (pull_request) Successful in 8s
CI / changes (pull_request) Successful in 9s
CI Trade-In / backend-tests (pull_request) Has been skipped
CI Trade-In / frontend-checks (pull_request) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Successful in 2m1s
CI / backend-tests (pull_request) Successful in 14m32s

Postgres не принимает bind-параметры в SET (extended protocol →
psycopg.errors.SyntaxError «at or near $1»), запрос падал и деградация
отдавала [] на каждый вызов. Литерал из int-константы, как у offer_trend.
Проверено на прод-БД через туннель: 66:41:0404019:4728 → 6 зон
(thermal 3 м / 8 м, электро 58 м, газ 125 м).
This commit is contained in:
bot-backend 2026-07-03 13:28:52 +05:00
parent 8a42fba836
commit 183053f890

View file

@ -523,10 +523,9 @@ def _query_nearby_network_zones(db: Session, parcel_wkt: str) -> list[dict]:
"""
try:
with db.begin_nested():
db.execute(
text("SET LOCAL statement_timeout = :ms"),
{"ms": str(_NETWORK_ZONE_TIMEOUT_MS)},
)
# SET не принимает bind-параметры (extended protocol → syntax error
# at or near "$1") — только литерал, как у offer_trend (parcels.py).
db.execute(text(f"SET LOCAL statement_timeout = '{_NETWORK_ZONE_TIMEOUT_MS:d}'"))
rows = (
db.execute(
text("""