feat(tradein): API домов «доли квартир в продаже» — /buildings/sale-share (+ listings, summary) #2055
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#2055
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/tradein-sale-share-api"
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
Backend для страницы
gendsgn.ru/trade-in/sale-share. 3 endpoint'а поверх готового viewv_building_sale_share(миграция 143, уже в main) — логику доли не пересчитываю, читаю как есть.GET /api/v1/buildings/sale-share— список вторичных домов сsale_share_pct >= min_pct. Фильтры:min_pct(=5)/max_pct/city(ILIKE)/price_min/price_max(median)/year_min/year_max/house_type/sort/limit(1..1000). Флагover_100для неправдоподобных матчей (показываю, не прячу).GET /api/v1/buildings/{house_id}/listings— активная вторичка дома (для клик-дровера со ссылками на источник).GET /api/v1/buildings/sale-share/summary— total / with-denominator / coverage_pct / max / p95 + гистограмма по 7 корзинам — для ползунка % и баннера покрытия.Новые файлы:
api/v1/buildings.py,services/buildings_query.py,schemas/buildings.py, +main.py(router), +tests/test_buildings_api.py(17 тестов).Качество
text()+ bind, вездеCAST(:x AS type)(psycopg v3);sort— двойной whitelist (router pattern + service map с fallback), user-ввод в SQL не попадает.median_*черезCAST(round(...) AS bigint)—percentile_contотдаёт double, иначе Pydantic int падает на дробном.Test plan
test_search_cache_hit— pre-existing (401 RBAC, идентично на чистом main).sale_share_pct=34.0%, после ROLLBACK ничего не записано.docker exec tradein-backend curl -s localhost:8000/api/v1/buildings/sale-share/summary -H "X-Authenticated-User: admin".Часть серии: PR2/4 (API). Знаменатель заполнит ГАР-loader; фронт-страница — следующий PR.