|
|
20b4a195b3
|
feat(tradein): Phase 2-3 of #582 — backfill houses + canonical reverse audit
Builds on Phase 1 audit infra (PR #583). Forward-geocode 4141 houses
без coords + reverse audit 4452 already-geocoded houses через Yandex
Geocoder API. Verified mismatch 870м для «Малышева 125» — наш point
в другом квартале от реального здания.
Scripts (new):
- `backfill_house_coords.py` (619 LOC) — driver:
* Forward mode: UPDATE houses SET lat/lon когда precision ∈ {exact, number}
* `--audit-only`: reverse геокод + distance check, flag >50м как mismatch
* Per-row SAVEPOINT, idempotent через UNIQUE (house_id, audit_batch)
* EKB locality bias (ll=60.6122,56.8389, spn=0.6,0.4)
* Rate-limit 50ms между запросами, 25k/день квота Yandex покрывает 8.5k houses
- `_yandex_reverse.py` (+123 LOC) — added `forward_via_api()`,
precision/kind в YandexReverseResult dataclass
- `audit_address_sample.sql` (-7 +47) — FIX: убрана зависимость от FDW
`gendesign_ekb_districts_geom` (нет на проде). Простой
`ORDER BY random()` без district stratification. Bind-param контракт
сохранён (`:limit_per_district` * 8 = 200 default).
Tests:
- `test_backfill_house_coords.py` (510 LOC) — 20 tests: request shape,
precision filter, UPDATE shape, backfill happy/imprecise/no_match/error,
audit ok/mismatch/no_match, resumability, missing-key exit, mode routing
- Existing `test_audit_address_mismatch.py` still green
- 39/39 pass, ruff clean
Decisions (см. PR body):
- Precision filter = {exact, number} only (street/range/near → audit-imprecise)
- Mismatch threshold 50м (consistent с Phase 1 report)
- API-only (no Playwright fallback) — exit если key missing
Closes #582 (Phase 2-3 portion; Phase 1 was #583)
|
2026-05-27 11:30:25 +05:00 |
|