fix(sf-07): median_12m alias + UI 12mo hint #280
2 changed files with 8 additions and 3 deletions
|
|
@ -1188,16 +1188,20 @@ def analyze_parcel(
|
|||
geom_wkt: str = geom_row["wkt"] # type: ignore[index]
|
||||
|
||||
# 2) District context — ближайший район ЕКБ
|
||||
# median_price_per_m2: предпочитаем median_12m из mv_quarter_price_per_m2 (12 мес),
|
||||
# fallback на ekb_districts.median_price_per_m2 (24 мес).
|
||||
district_row = (
|
||||
db.execute(
|
||||
text("""
|
||||
SELECT district_name,
|
||||
median_price_per_m2,
|
||||
SELECT d.district_name,
|
||||
COALESCE(mq.median_12m, d.median_price_per_m2) AS median_price_per_m2,
|
||||
ST_Distance(
|
||||
d.geom::geography,
|
||||
ST_Centroid(ST_GeomFromText(:wkt, 4326))::geography
|
||||
) AS dist_to_center
|
||||
FROM ekb_districts d
|
||||
LEFT JOIN mv_quarter_price_per_m2 mq
|
||||
ON mq.quarter_cad_number = REGEXP_REPLACE(:cad_num, ':[^:]+$', '')
|
||||
WHERE ST_DWithin(
|
||||
d.geom::geography,
|
||||
ST_Centroid(ST_GeomFromText(:wkt, 4326))::geography,
|
||||
|
|
@ -1206,7 +1210,7 @@ def analyze_parcel(
|
|||
ORDER BY dist_to_center ASC
|
||||
LIMIT 1
|
||||
"""),
|
||||
{"wkt": geom_wkt},
|
||||
{"wkt": geom_wkt, "cad_num": cad_num},
|
||||
)
|
||||
.mappings()
|
||||
.first()
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ export function OverviewTab({ data, onIsochronesResult }: Props) {
|
|||
<strong style={{ color: "#374151" }}>
|
||||
{(data.district.median_price_per_m2 / 1000).toFixed(0)} тыс ₽/м²
|
||||
</strong>
|
||||
<span className="text-xs text-slate-500 ml-1">(12 мес)</span>
|
||||
<span style={{ marginLeft: 12 }}>
|
||||
{(data.district.dist_to_center / 1000).toFixed(1)} км до центра
|
||||
</span>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue