Merge pull request 'fix(recommend): cad_buildings.floors is INTEGER not TEXT (HOTFIX)' (#218) from fix/recommend-mix-floors-integer into main
All checks were successful
Deploy / changes (push) Successful in 5s
Deploy / build-backend (push) Successful in 2m56s
Deploy / build-frontend (push) Has been skipped
Deploy / build-worker (push) Successful in 3m30s
Deploy / deploy (push) Successful in 57s

This commit is contained in:
lekss361 2026-05-16 16:00:23 +00:00
commit 99372a211f

View file

@ -1349,10 +1349,9 @@ def _district_cadastre_baseline(db: Session, *, district_name: str) -> dict[str,
WHERE cb.cost_value IS NOT NULL
AND cb.area IS NOT NULL
AND cb.area >= 100
-- floors хранится как TEXT (встречаются '1-2', '2-3')
-- считаем только чистые числа 3, либо purpose-fallback.
AND ((cb.floors ~ '^[0-9]+$' AND cb.floors::int >= 3)
OR cb.purpose ILIKE '%многокв%')
-- floors INTEGER (Rosreestr ETL приводит к int); NULL = unknown.
-- Считаем МКД если floors 3 или purpose содержит «многокв».
AND (cb.floors >= 3 OR cb.purpose ILIKE '%многокв%')
AND (cb.cost_value / NULLIF(cb.area, 0))
BETWEEN 5000 AND 500000
)