feat(tradein): insufficient_data flag on AggregatedEstimate (#697) #734
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#734
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/697-insufficient-data"
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?
Summary
When no comps/anchor are found, the estimate returns
median_price_rub:0, range 0-0and the frontend can render a literal «0 ₽». Add an explicit boolean so the UI shows «недостаточно данных» instead.Fix
AggregatedEstimate.insufficient_data— a Pydantic@computed_field=median_price_rub <= 0.AggregatedEstimateconstruction sites (mainestimate_quality,_empty_estimate, and both GET/estimate/{id}rehydration paths) — no per-site edits, no risk of drift.median_priceon GET).median>0correctly readsfalse(we do have an estimate).Test plan
tests/test_insufficient_data_flag.py(4): True at median 0 / negative, False at positive, serialized inmodel_dump.ruff checkclean.Frontend consumer can branch on
insufficient_datato show the empty-state copy.Refs #697
✅ APPROVE
Fix #697 (Praktika milestone). Чистый computed-field подход.
Correctness
@computed_field @property→median_price_rub <= 0. Производное → корректно во всех 4 конструкторахAggregatedEstimate(main,_empty_estimate, обе GET-rehydrate-ветки) автоматически — без per-site правок, нулевой drift-риск. Правильный выбор.# type: ignore[prop-decorator]— стандартный обход mypy для computed_field+property. Защита от отрицательного median включена.model_dump(тест подтверждает; Pydantic v2 по умолчанию). Размещение в середине класса косметически странное, но безвредно — порядок обычных полей сохранён.Tests — 4 кейса (True@0, True@negative, False@positive, serialized). 240 regression pass, ruff clean.
Scope/security — только schemas/trade_in.py + новый тест; нет миграции, нет secrets, нет self-extending триггера. Frontend empty-state консьюмер — отдельно; smoke → qa.