gendesign/tradein-mvp/backend
lekss361 7af97c2c59 feat(tradein): integrate Avito IMV as 5th evaluation source (on-demand cached)
Stage 3 of AvitoScraper_v2.

- _get_or_fetch_imv_cached(db, **params) — TTL 24h по cache_key (sha256 of address+params)
  * Cache HIT: SELECT avito_imv_evaluations WHERE cache_key AND fetched_at > NOW() - 24h
  * Cache MISS: evaluate_via_imv + save_imv_evaluation (2 HTTP requests to Avito)
  * Graceful: на любой error → return None, estimator продолжает без IMV
- В estimate_quality после aggregation:
  * Map house_type/repair_state → Avito IMV формат (_IMV_HOUSE_TYPE_MAP, _IMV_REPAIR_MAP)
  * Skip IMV если payload без required fields (rooms/area/floor/total_floors/house_type/repair)
  * Append 'avito_imv' в sources_used (saved + returned)
- После INSERT estimate: link estimate_id в avito_imv_evaluations row (для analytics joining)
- Logging: imv=<price> в final estimate log line
- pytest offline (4 tests): house_type_map / repair_map / cache_miss_fetch / fetch_failure_graceful
  * anyio.run() вместо pytest-asyncio (не установлен в tradein-mvp venv)
  * DATABASE_URL dummy через os.environ.setdefault (Settings fail-fast без него)

IMV — ON-DEMAND only (per estimator call), НЕ в cron-scrape.
Refs: AvitoScraper_v2_Implementation_Plan Stage 3.
2026-05-23 15:48:50 +03:00
..
app feat(tradein): integrate Avito IMV as 5th evaluation source (on-demand cached) 2026-05-23 15:48:50 +03:00
data/sql feat(tradein): SQL migration 029 — extend matching/valuation/dynamics tables (PR #445 follow-up) (#448) 2026-05-23 12:35:03 +00:00
tests feat(tradein): integrate Avito IMV as 5th evaluation source (on-demand cached) 2026-05-23 15:48:50 +03:00
.dockerignore feat: add tradein-mvp subproject (Trade-In Estimator под /trade-in) 2026-05-21 00:25:39 +03:00
Dockerfile feat: add tradein-mvp subproject (Trade-In Estimator под /trade-in) 2026-05-21 00:25:39 +03:00
pyproject.toml feat(tradein): мониторинг ошибок через GlitchTip (#396) 2026-05-22 11:18:26 +05:00