All checks were successful
CI Trade-In / changes (pull_request) Successful in 7s
CI / changes (pull_request) Successful in 8s
CI Trade-In / frontend-checks (pull_request) Has been skipped
CI / backend-tests (pull_request) Has been skipped
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Has been skipped
CI Trade-In / backend-tests (pull_request) Successful in 1m36s
Финальный PR issue #2045 (BE-3): GET /api/v1/trade-in/location-coef для LocationDrawer. FDW foreign table -> локальное зеркало osm_poi_ekb_local (TRUNCATE+INSERT, тот же паттерн что cad_buildings_local/cadastral_geo_match, избегает ~1.16s/row FDW round-trip) -> straight-line POI-скоринг, портированный из Site Finder poi_score.py::compute_poi_weighted_top7 (CATEGORY_WEIGHTS as-is, радиус 1200м для квартир вместо Ptica 2000м для участков). score->coef - новая MVP-эвристика (0.95..1.05, не откалибрована на реальных дельтах). Graceful fallback (не 500, не фабрикуем факторы): пустая/не отрефрешенная osm_poi_ekb_local или отсутствие lat/lon у оценки -> coef=1.0, factors=[], geo_source="unavailable". Scheduler: source=osm_poi_ekb_refresh, daily, зарегистрирован и в боевом dispatch (scheduler.py), и в kit-registry (product_handlers.py) - иначе test_kit_registry_completeness падает на ship-dark инварианте (#2192). Frontend wiring (mappers.ts/LocationDrawer.tsx) - вне scope, отдельная задача после проверки endpoint'а curl'ом на деплое.
36 lines
1.4 KiB
PL/PgSQL
36 lines
1.4 KiB
PL/PgSQL
-- 168_fdw_osm_poi_ekb.sql
|
|
-- FDW foreign table bridging to gendesign's v_tradein_osm_poi_ekb view for
|
|
-- location-coef / POI scoring in LocationDrawer (#2045, BE-3 final PR).
|
|
--
|
|
-- Mirrors 060_postgres_fdw_extension.sql conventions: uses the SAME SERVER
|
|
-- gendesign_remote (already created there) — this migration does NOT create a new
|
|
-- SERVER / USER MAPPING.
|
|
--
|
|
-- DEPENDENCIES:
|
|
-- - 060_postgres_fdw_extension.sql (SERVER gendesign_remote + USER MAPPING, managed by
|
|
-- backend startup with env password).
|
|
-- - gendesign: view public.v_tradein_osm_poi_ekb + GRANT SELECT to tradein_fdw_reader
|
|
-- (PR-A of #2045, already merged + deployed on gendesign).
|
|
--
|
|
-- Idempotent: DROP FOREIGN TABLE IF EXISTS + re-CREATE.
|
|
|
|
BEGIN;
|
|
|
|
DROP FOREIGN TABLE IF EXISTS gendesign_osm_poi_ekb;
|
|
|
|
CREATE FOREIGN TABLE gendesign_osm_poi_ekb (
|
|
category text,
|
|
name text,
|
|
lat double precision,
|
|
lon double precision
|
|
)
|
|
SERVER gendesign_remote
|
|
OPTIONS (schema_name 'public', table_name 'v_tradein_osm_poi_ekb');
|
|
|
|
COMMENT ON FOREIGN TABLE gendesign_osm_poi_ekb IS
|
|
'Live view of gendesign.osm_poi_ekb (Site Finder OSM POI, EKB). USER MAPPING managed by '
|
|
'backend startup (see 060). Materialized locally by the osm_poi_ekb_refresh scheduler job '
|
|
'into osm_poi_ekb_local (migration 169) — see app/tasks/osm_poi_ekb_refresh.py. '
|
|
'Feeds app/services/location_coef.py (GET /api/v1/trade-in/location-coef).';
|
|
|
|
COMMIT;
|