fix(tradein): GET /estimate/{id} возвращает полный набор полей
При открытии оценки по ссылке (?id=) или перезагрузке страницы get_estimate отдавал огрызок: без sources_used, confidence_explanation, target_address, координат, data_freshness_minutes. Из-за этого карточка «Сбор данных по квартире» пустела до «0 / 7 источников · ожидает запрос» — хотя данные в БД есть. Теперь SELECT и ответ включают полный набор полей AggregatedEstimate. period_months 24 → 12 (совпадает с estimator / DEALS_PERIOD_MONTHS).
This commit is contained in:
parent
a1cd5e293e
commit
18c2e64182
1 changed files with 13 additions and 3 deletions
|
|
@ -297,8 +297,9 @@ def get_estimate(
|
|||
text(
|
||||
"""
|
||||
SELECT id, median_price, range_low, range_high, median_price_per_m2,
|
||||
confidence, n_analogs, analogs, actual_deals, expires_at,
|
||||
address, area_m2, rooms
|
||||
confidence, confidence_explanation, n_analogs,
|
||||
analogs, actual_deals, sources_used, data_freshness_minutes,
|
||||
expires_at, address, lat, lon
|
||||
FROM trade_in_estimates
|
||||
WHERE id = CAST(:id AS uuid)
|
||||
AND expires_at > NOW()
|
||||
|
|
@ -313,6 +314,9 @@ def get_estimate(
|
|||
analogs = [AnalogLot(**a) for a in (row.analogs or [])]
|
||||
actual_deals = [AnalogLot(**a) for a in (row.actual_deals or [])]
|
||||
|
||||
# ВАЖНО: возвращаем ПОЛНЫЙ набор полей. Раньше эндпоинт отдавал огрызок
|
||||
# без sources_used / confidence_explanation / координат — и при открытии
|
||||
# оценки по ссылке (?id=) карточка источников пустела до «0/7».
|
||||
return AggregatedEstimate(
|
||||
estimate_id=row.id,
|
||||
median_price_rub=row.median_price,
|
||||
|
|
@ -320,11 +324,17 @@ def get_estimate(
|
|||
range_high_rub=row.range_high,
|
||||
median_price_per_m2=row.median_price_per_m2,
|
||||
confidence=row.confidence,
|
||||
confidence_explanation=row.confidence_explanation,
|
||||
n_analogs=row.n_analogs,
|
||||
period_months=24,
|
||||
period_months=12,
|
||||
analogs=analogs,
|
||||
actual_deals=actual_deals,
|
||||
expires_at=row.expires_at,
|
||||
target_address=row.address,
|
||||
target_lat=row.lat,
|
||||
target_lon=row.lon,
|
||||
sources_used=row.sources_used or [],
|
||||
data_freshness_minutes=row.data_freshness_minutes,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue