From 4a93a9297cc983cf3987acfadd299ba1e1ec67e7 Mon Sep 17 00:00:00 2001 From: lekss361 Date: Sat, 27 Jun 2026 17:30:34 +0000 Subject: [PATCH] fix(tradein/avito): persist house_type + house_catalog_url in save_detail_enrichment (#2009) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit house_type (normalized) + house_catalog_url→house_url persisted in save_detail_enrichment; COALESCE existing-first for house_type, new-first for house_url. No migration (columns exist). Refs #2009 --- .../app/services/scrapers/avito_detail.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tradein-mvp/backend/app/services/scrapers/avito_detail.py b/tradein-mvp/backend/app/services/scrapers/avito_detail.py index 24192abc..a17d61ad 100644 --- a/tradein-mvp/backend/app/services/scrapers/avito_detail.py +++ b/tradein-mvp/backend/app/services/scrapers/avito_detail.py @@ -677,8 +677,16 @@ def save_detail_enrichment(db: Session, e: DetailEnrichment) -> bool: Returns True если строка обновлена, False если listing не найден. Устанавливает detail_enriched_at=NOW(). - House-level поля (passenger_elevators, has_concierge, closed_yard, - total_floors_house, house_type) игнорируются — canonical из Houses Catalog (Stage 2c). + + house_type СОХРАНЯЕТСЯ (уже нормализован парсером → канон panel/brick/monolith/ + monolith_brick/block/wood) — нужен estimator soft-penalty по типу дома. + house_catalog_url СОХРАНЯЕТСЯ в listings.house_url (линковка дома); отдельной + house_catalog_url колонки нет. house_type — COALESCE existing-first (не затираем + canonical из Houses Catalog Stage 2c); house_url — new-first additive (avito-owned + поле, нет конкурирующего canonical-писателя). + Остальные house-level поля (passenger_elevators, cargo_elevators, has_concierge, + closed_yard, total_floors_house) по-прежнему опускаются — нет колонок в listings, + canonical приходит из Houses Catalog Stage 2c (отдельный follow-up). """ result = db.execute( text(""" @@ -713,6 +721,8 @@ def save_detail_enrichment(db: Session, e: DetailEnrichment) -> bool: total_floors = COALESCE(:total_floors, total_floors), repair_state = COALESCE(:repair_state, repair_state), price_rub = COALESCE(:price_rub, price_rub), + house_type = COALESCE(house_type, :house_type), + house_url = COALESCE(:house_catalog_url, house_url), detail_enriched_at = NOW() WHERE source = 'avito' AND source_id = :item_id """), @@ -750,6 +760,8 @@ def save_detail_enrichment(db: Session, e: DetailEnrichment) -> bool: "total_floors": e.total_floors, "repair_state": e.repair_state, "price_rub": e.price_rub, + "house_type": e.house_type, + "house_catalog_url": e.house_catalog_url, }, ) db.commit()