feat(tradein): add data_quality flag to /sales-vs-listings (#721) #723
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#723
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/721-data-quality-flag"
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
Per ADR variant 3 (human-decided, demo-critical): house-level ДКП↔listing join is physically impossible (
dealscarry only a street centroid — no house/cadastre). Instead of null-silence atlinkage=0, expose an honest enum so the frontend (#722, blocked on this) can distinguish the cases.Changes
SalesVsListingsResponse: new required fielddata_quality: str("house_linked" | "street_only" | "no_data"), placed betweenmedian_discount_pctandpairs._empty()→"no_data"(no deals / street not extracted)."house_linked" if deals_with_listings > 0 else "street_only". The main return is reached only withtotal_deals > 0(guarded byif not rows: return _empty(...)), sostreet_onlycorrectly means "deals exist, none house-linked".Both
SalesVsListingsResponse(...)construction sites (the only two in the codebase) set the field — no runtime break from the new required field.Out of scope (per ADR)
SQL
street_sales_vs_listings/ linkage /median_discount_pctlogic, cadastre/geo ingest & backfill, frontend (#722),/street-deals.Test plan
grep data_quality schemas/trade_in.py→ 1;grep data_quality api/v1/trade_in.py→ 2python -c "... assert 'data_quality' in SalesVsListingsResponse.model_fields"→ OKruff check(api + schemas) → cleanpytest -k sales_vs_listings→ 8 passedRefs #721
✅ APPROVE
Чистая аддитивная правка по спеку #721 (ADR variant 3).
Correctness
data_quality: strдобавлен междуmedian_discount_pctиpairs— ровно как в контракте._empty()→"no_data", main return →"house_linked" if deals_with_listings > 0 else "street_only". Grep подтвердил: в кодовой базе только 2 сайта (1575, 1680). Required-field без дефолта → риск runtime-break закрыт.street_onlyкорректно недостижим приtotal_deals==0(guardif not rows: return _empty(...)выше).No regression
test_sales_vs_listings_response_shapeиспользуетissubset, не exact-equality → новый ключ не валит тест. Все 8 тестов проходят.Scope/security — затронут только tradein backend; нет secrets, нет self-extending триггера.