coef = 0.95 + score/100*0.10 не был связан с ценой и не участвовал в расчёте estimator'а вовсе (0 упоминаний), но интерфейс рисовал «база -> результат», обещая влияние на цену. Замеры на боевой БД: по 1500 адресам ЕКБ 67% попадают в -1%..+1%, весь город укладывается в размах 1.10x; медиана руб/м2 по бакетам коэффициента плоская и немонотонная (бакет -4% дороже бакета +3%). Для сравнения, расстояние до центра даёт монотонный градиент с размахом 2.70x (93 677 -> 249 686 руб/м2 по 31 тыс. лотов). Новый показатель — отклонение медианы руб/м2 сопоставимых активных листингов в радиусе от медианы по городу (percentile_cont, лестница радиусов до набора выборки). Честная деградация вне ЕКБ и при малой выборке вместо молчаливого вырождения в 0.95. В цену по-прежнему не идёт — аналоги берутся из того же района, локация в базовой цене уже учтена. Заодно две причины потери POI: 1. Overpass-фильтр метро ловил только station=subway, без railway=station+subway=yes. 2. v_tradein_osm_poi_ekb резала всё, что не редактировали в OSM 2 года. Проверено на проде: из 5133 точек доходило 2787 (-46%), причём смещённо — парки -84%, больницы -80%, магазины -83%, остановки 0%. Из 9 станций метро терялись 4, включая Площадь 1905 года. Станция не перестаёт существовать оттого, что её тег два года не трогали; Site Finder использует эту дату как мягкий сигнал уверенности, а не как фильтр существования.
48 lines
2.6 KiB
PL/PgSQL
48 lines
2.6 KiB
PL/PgSQL
-- 188_tradein_osm_poi_view_relax_freshness.sql
|
|
-- Fix for 185_tradein_osm_poi_view.sql: v_tradein_osm_poi_ekb enforced a HARD 2-year
|
|
-- OSM last-edit-date filter that silently dropped legitimate, stable infrastructure.
|
|
--
|
|
-- CONTEXT (trade-in location-index rework, replaces the broken location-coef):
|
|
-- Audit of the trade-in POI mirror (osm_poi_ekb_local, fed by this view via the FDW
|
|
-- bridge) found only 5 of 9 EKB metro stations and just 2787 POI total reaching
|
|
-- tradein-mvp, despite osm_poi_ekb (this table, Site Finder's own registry) having more.
|
|
--
|
|
-- Root cause: this view's WHERE clause dropped any POI whose OSM `last_osm_edit_date` is
|
|
-- older than 2 years. A subway station node, once correctly mapped, is essentially never
|
|
-- re-edited in OSM — "stale last edit" here means "nobody touched this tag in years",
|
|
-- NOT "this station stopped existing". The same logic applies to schools/hospitals/parks:
|
|
-- physically permanent infrastructure that simply isn't re-edited often.
|
|
--
|
|
-- The "2-year freshness" requirement itself (see 82_osm_poi_ekb.sql, "требование
|
|
-- Максима") was intended as a SOFT confidence signal, not a hard existence filter — Site
|
|
-- Finder itself (backend/app/api/v1/parcels.py, "POI freshness" confidence subscore) only
|
|
-- uses last_osm_edit_date to DERATE a confidence score; every POI stays in the result set
|
|
-- regardless of staleness. This view diverged into a hard filter when the FDW bridge was
|
|
-- built (185) — this migration fixes that divergence, matching Site Finder's own intent.
|
|
--
|
|
-- WHAT: CREATE OR REPLACE VIEW, same 4-column shape as 185 (category, name, lat, lon) — no
|
|
-- WHERE clause. tradein-mvp's FDW foreign table (tradein-mvp/backend/data/sql/
|
|
-- 168_fdw_osm_poi_ekb.sql) is untouched — same column list, so no FDW-side change needed.
|
|
--
|
|
-- Idempotent: CREATE OR REPLACE VIEW. GRANT re-applied (idempotent, matches 185).
|
|
|
|
BEGIN;
|
|
|
|
CREATE OR REPLACE VIEW v_tradein_osm_poi_ekb AS
|
|
SELECT
|
|
category,
|
|
name,
|
|
lat,
|
|
lon
|
|
FROM osm_poi_ekb;
|
|
|
|
GRANT SELECT ON v_tradein_osm_poi_ekb TO tradein_fdw_reader;
|
|
|
|
COMMENT ON VIEW v_tradein_osm_poi_ekb IS
|
|
'FDW source for tradein-mvp (postgres_fdw) location-index/nearby-POI list (replaces the '
|
|
'broken location-coef, #2045). No freshness filter — last_osm_edit_date is a soft '
|
|
'confidence signal only (see Site Finder parcels.py), not evidence a POI stopped '
|
|
'existing. Fixes 185_tradein_osm_poi_view.sql hard 2-year WHERE filter that silently '
|
|
'dropped 4/9 EKB metro stations + other stable infrastructure from the trade-in mirror.';
|
|
|
|
COMMIT;
|