fix(tradein/cian): sanitize valuation cache writes (047 UNIQUE + 026/044 cols) #523

Merged
lekss361 merged 1 commit from feat/cian-history-sanitize into main 2026-05-24 13:44:39 +00:00

1 commit

Author SHA1 Message Date
lekss361
d04ee38347 fix(tradein/cian): sanitize valuation cache writes (047 UNIQUE, fill 026+044 cols)
- 047_cian_history_sanitize.sql: dedup existing rows then add
  UNIQUE(listing_id, change_time) so ON CONFLICT DO NOTHING in
  cian_detail.save_detail_enrichment suppresses real duplicates,
  not just PK collisions. Idempotent via DO $$ pg_constraint guard.
- cian_valuation._save_to_cache: fill price_rub/accuracy (mig 026),
  low_price/high_price (mig 044), house_id/listing_id (mig 044).
  COALESCE on house_id/listing_id preserves existing FK on cache refresh.
- cian_valuation._load_from_cache: restore low_price/high_price from DB
  into sale_price_from/sale_price_to so callers get the full band.
- estimate_via_cian_valuation: add house_id/listing_id kwargs (default None),
  pass through to _save_to_cache. No callsite changes needed (defaults preserve
  existing behavior; PR 4 can supply IDs when context is available).
2026-05-24 16:34:32 +03:00