fix(tradein-phase-c): prepend region prefix for IMV geocoder #540
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#540
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/tradein-phase-c-region-prefix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Live Phase C dry-run на проде показал ~30% HTTP 404 от Avito IMV. Логирование response body (added in PR #537) показало
{"code":404,"message":"Not Found"}. Причина — Avito/coords/by_addressmis-resolves ambiguous addresses to wrong regions:улица Академика Королева, 8Гр-н Орджоникидзевский, мкр. Уралмаш...р-н Кировский, ул. Студенческая, 1Нк4Наши
houses.addressдля derived rows часто содержат только district + street без региона. Avito picks ANY matching location.Fix
scripts/backfill-house-imv.py:_REGION_BBOX— bounding box → region name (EKB, Свердловская обл, Киров, Ставрополь, Тюмень, Челябинск)_REGION_DEFAULT = 'Свердловская область, Екатеринбург'для NULL coords_detect_region_prefix(lat, lon)— walks bboxes_enrich_address_for_imv(raw, lat, lon)— skip если естьобласть,/обл./край/респ., иначе prepend prefixprocess_one()использует enriched address для evaluate_via_imvVerify after deploy
Re-run failed houses:
Follow-up
Follow-up к PR #534 (Phase C kickoff), #537 (house_type mapping + 400 logging). Roadmap chain so far: 9/9 original + IMV + 3 backfill + Phase C kickoff + 2 phase-C fixups.
hello world
Deep Code Review — PR #540 verdict
Summary
57dd989e58Why approve
scripts/backfill-house-imv.py) — does NOT touch production estimator. Blast radius minimal.logger.debug— good restraint, no log spam at INFO).MEDIUM — region-marker substrings miss common shapes (worth a follow-up)
Marker substrings require a comma immediately after the marker word. Real inputs that slip through and get prefixed with EKB anyway:
Республика Татарстан, Казаньреспублика,is not present — actual text isреспубликаEKB, Республика Татарстан, Казань(double region)Респ. Татарстан, Казаньресп.,not present — actual isресп.Свердловская область(bare)EKB, Свердловская областьСвердловская обл.(bare)Suggested fix next PR: use word-presence match without requiring trailing comma:
MEDIUM — non-bbox houses (incl. Moscow/SPb) silently get EKB prefix
_REGION_DEFAULT = "Свердловская область, Екатеринбург"is applied to ANY lat/lon outside the 6 listed bboxes. Misclassifications:If current dataset has no such rows — fine. Worth adding a WARN log when
_detect_region_prefixfalls back to default, so future non-EKB rows are visible in batch logs.LOW — cache_key divergence between backfill and live estimator
compute_imv_cache_keyis keyed on raw address.Свердловская обл, Екатеринбург, ул. X, 1).backend/app/services/estimator.py:189) computes with rawhouse.address→ cache MISS → duplicate Avito API call.Not a correctness issue (extra API call, not stale data), but defeats the 24h dedup goal. Future cleanup: push enrichment into
evaluate_via_imv()or normalize beforecompute_imv_cache_key.LOW — possible city duplication for already-city-qualified addresses
Address like
Екатеринбург, ул. Победы, 1(no region marker, just city) enriches toСвердловская область, Екатеринбург, Екатеринбург, ул. Победы, 1. Likely tolerated by Avito but inelegant.LOW — no unit test for
_enrich_address_for_imvA 10-line
test_enrich_address_for_imv.pyparameterized over the marker-detection table would have caught issue #1. Not a blocker for a backfill script.Cross-file impact
evaluate_via_imv(address=...)— only call site changed isprocess_one()in this script. Estimator service unchanged.compute_imv_cache_key— not modified; address-key divergence noted above.Positive
if enriched != address: logger.debug(...)— diff-only logging, no log spam.Recommended follow-ups (not blocking)
evaluate_via_imvso estimator + backfill share cache (issue #3).test_enrich_address_for_imvtable-driven test.Complexity / blast radius
Posting verdict and auto-merging per any-scope policy.