feat(location): district Location entity + indices (#948 part B) #1166

Merged
bot-backend merged 1 commit from feat/location-948b-r into main 2026-06-08 08:29:02 +00:00
Collaborator

Что

#948 Part B — «Локация» first-class entity (§8.2), АДДИТИВНО. Завершает #948 (Part A insight #1164). Ребейзнутая ветка (чистая линейная история поверх #1164+#962; main.py-конфликт router-include разрешён — оба роутера).

Новая таблица location (ключ district_name) + 4 нормализованных [0,1] индекса (NULL при отсутствии, не фабричный 0), переиспользуя per-district forecast-функции:

  • infra: _district_poi_score / _city_avg_poi_score
  • competition: market_metrics.overstock_index (доступный/залежавшийся конкурирующий сток — ортогонально demand, не sell-through) ← semantic-фикс по ревью
  • demand: market_metrics.unit_velocity (saturating /50)
  • future_supply: future_supply_pressure.index (passthrough)

146_location.sql (idempotent, range-CHECK, centroid GIST) + locations.py service (SAVEPOINT, CAST, ON CONFLICT) + Celery task+beat (Пн 07:00) + read-API.

Качество

code-reviewer: gates (SQL+миграция); semantic-фикс competition⊥demand внесён + доказан тестом. 34 location + 156 regression, ruff, без deps. Аддитивно (parcels.py не тронут). Refs #948.

## Что #948 **Part B — «Локация» first-class entity** (§8.2), АДДИТИВНО. Завершает #948 (Part A insight #1164). Ребейзнутая ветка (чистая линейная история поверх #1164+#962; main.py-конфликт router-include разрешён — оба роутера). Новая таблица `location` (ключ district_name) + 4 нормализованных [0,1] индекса (NULL при отсутствии, не фабричный 0), переиспользуя per-district forecast-функции: - **infra:** `_district_poi_score / _city_avg_poi_score` - **competition:** `market_metrics.overstock_index` (доступный/залежавшийся конкурирующий сток — **ортогонально demand**, не sell-through) ← semantic-фикс по ревью - **demand:** `market_metrics.unit_velocity` (saturating /50) - **future_supply:** `future_supply_pressure.index` (passthrough) `146_location.sql` (idempotent, range-CHECK, centroid GIST) + `locations.py` service (SAVEPOINT, CAST, ON CONFLICT) + Celery task+beat (Пн 07:00) + read-API. ## Качество `code-reviewer`: ✅ gates (SQL+миграция); semantic-фикс competition⊥demand внесён + доказан тестом. **34 location + 156 regression**, ruff, без deps. Аддитивно (parcels.py не тронут). Refs #948.
bot-backend added the
scope/backend
GG-форсайт
site-finder
labels 2026-06-08 08:28:59 +00:00
bot-backend added 1 commit 2026-06-08 08:28:59 +00:00
feat(location): district-level Location entity + indices (#948 part B)
All checks were successful
CI / changes (push) Successful in 6s
CI / frontend-tests (push) Has been skipped
CI / changes (pull_request) Successful in 6s
Deploy / changes (push) Successful in 6s
CI / frontend-tests (pull_request) Has been skipped
Deploy / build-backend (push) Successful in 1m29s
Deploy / build-frontend (push) Has been skipped
Deploy / build-worker (push) Successful in 2m42s
Deploy / deploy (push) Successful in 1m11s
CI / backend-tests (push) Successful in 6m27s
CI / backend-tests (pull_request) Successful in 6m22s
8da1c00138
Promote district to a first-class `location` entity (ТЗ §8.2), ADDITIVE — no
district->FK refactor. New `location` table keyed by district_name (joinable by
string), carrying 4 normalized [0,1] indices (NULL when no data, never 0):
- infra: _district_poi_score / _city_avg_poi_score (per-district POI aggregate)
- competition: market_metrics.overstock_index (available/stuck competing supply
  — orthogonal to demand; NOT sell-through, which is market-heat correlated w/ demand)
- demand: market_metrics.unit_velocity (saturating /50)
- future_supply: future_supply_pressure.index (passthrough, already 0..1)

- data/sql/146_location.sql: idempotent table + UNIQUE(district_name) + range
  CHECK + centroid GIST
- services/site_finder/locations.py: compute_location_indices (reuses forecast
  per-district fns) + refresh_locations (SAVEPOINT per-row, CAST, ON CONFLICT)
- workers/tasks/location_refresh.py + beat (Mon 07:00 MSK, after supply-layers)
- api/v1/locations.py: read-only GET list + GET by name (analyst+admin via rbac,
  frontend pilot-gated)
- tests: 34 (normalization 0..1/null, competition⊥demand orthogonality, idempotent
  upsert, read API list/by-name/404)

Part of #948 (Part A insight shipped #1164).
bot-backend merged commit 8da1c00138 into main 2026-06-08 08:29:02 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#1166
No description provided.