feat(site-finder): weight profiles endpoints + analyze integration (#114 sub-PR 3/4) #138
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#138
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/114-weight-profiles-endpoints"
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
#114 sub-PR 3 of 4. Admin CRUD endpoints + minimal analyze_parcel integration.
Changes
backend/app/api/v1/admin_weight_profiles.py(102 lines) — full CRUD under AdminTokenAuthparcels.py— 3 minimal changes (new optional query params, resolve_weights call, response field)main.py— router registrationtests/test_admin_weight_profiles.py(351 lines, 13 tests)Endpoints
/api/v1/admin/site-finder/weight-profiles?user_id=X/api/v1/admin/site-finder/weight-profiles/api/v1/admin/site-finder/weight-profiles/{id}?user_id=X/api/v1/admin/site-finder/weight-profiles/{id}?user_id=X/api/v1/admin/site-finder/weight-profiles/{id}?user_id=Xanalyze_parcel integration (non-breaking)
New optional query params:
profile_id: int | Noneprofile_user_id: str | NoneIf both omitted →
source: \"system\"(defaults from_POI_WEIGHTS).If
profile_idgiven → load profile, use weights override.Else if
profile_user_id→ use user's default profile.Response gains:
Tests
46/46 pass (33 pre-existing + 13 new). Covers:
Refs: #114
Bot review (SHA
c8e510c, CI ✅)Чистая интеграция #114 sub-PR 3/4. Non-breaking, full CRUD, transparent response field.
Endpoints
✅ 5 RESTful endpoints под
/api/v1/admin/site-finder/weight-profiles— все подAdminTokenAuth(consistent с PR #133)✅ User-scoped CRUD —
user_idQuery на list/get/update/delete защищает cross-user access✅ HTTP semantics: 201 для POST, 204 для DELETE, 404 для missing — RESTful
✅
response_modelper endpoint — proper OpenAPI schema✅
min_length=1на user_id Query — отсечь empty stringparcels.py integration
✅ Non-breaking — 2 optional query params (
profile_id,profile_user_id); если оба None →source: "system"(backward-compatible behavior)✅ Late import
resolve_weights— circular-safe✅ Smart fallback chain в scoring loop:
Partial override работает корректно — если профиль задаёт только
school, остальные категории берутся из системных defaults.✅ Response transparency — новое поле
weights_profile.source("profile" | "user_default" | "system") +weights_appliedдля отладки из UImain.py
✅ Router зарегистрирован c
tags=["admin", "site-finder"]— корректно для OpenAPI группировкиМинор (UX, не блокер)
resolve_weightsвозвращает либо user dict, либо system dict — НЕ merged. Если профиль партиальный ({"school": 2.0}), то:_effective_weights = {"school": 2.0}.get(cat, _POI_WEIGHTS.get(...))fallback'у в parcels.py ✓weights_applied = {"school": 2.0}— показывает только customized keys, не отражает реально применённые веса (system defaults для остальных категорий невидимы в response)Не блокер:
_SYSTEM_POI_WEIGHTS+ user weights вresolve_weightsдо возвратаЭто сделает
weights_appliedtruth-telling и позволит убрать fallback в parcels.py scoring loop.Tests
46/46 (33 pre-existing + 13 new) — coverage CRUD happy paths + 422 validation + 404 missing + 401 auth, per PR body. CI green.
approve merge