fix(sf-08): add euro-1/euro-2 room_bucket for small-format rooms=2 flats
DOM.РФ API classifies euro-format flats (26-50м²) as rooms=2. _SUPPLY_BATCH_SQL now maps: rooms=2 + area<35 → 'euro-1' rooms=2 + area<50 → 'euro-2' before the generic rooms IN (1,2,3) branch. Audit: 4 140 units rooms=2 + area<35 in domrf_kn_flats were inflating the supply count for genuine 2-room apartments (median 57м²). euro buckets have no velocity counterpart in objective_corpus_room_month so they are filtered out of top_layouts by min_velocity. Also extends RoomBucket Literal and room_bucket_from_flat() in layout_signature.py with the new euro-1/euro-2 values. Closes #271 item 8
This commit is contained in:
parent
df2b47d27c
commit
b9259cd8ed
2 changed files with 18 additions and 5 deletions
|
|
@ -143,6 +143,11 @@ _SUPPLY_BATCH_SQL = text("""
|
|||
CASE
|
||||
WHEN f.is_studio = TRUE OR f.flat_type = 'Квартира-студия' THEN 'studio'
|
||||
WHEN f.rooms = 0 THEN 'studio'
|
||||
-- Fix SF-08: euro-форматы — DOM.РФ маркирует малогабаритные квартиры как 2-комн.
|
||||
-- rooms=2 + area<35 → euro-1 (студия с отдельной кухней ~26м²)
|
||||
-- rooms=2 + area<50 → euro-2 (~35-50м², евро-двушка)
|
||||
WHEN f.rooms = 2 AND f.total_area < 35 THEN 'euro-1'
|
||||
WHEN f.rooms = 2 AND f.total_area < 50 THEN 'euro-2'
|
||||
WHEN f.rooms IN (1, 2, 3) THEN f.rooms::text
|
||||
WHEN f.rooms >= 4 THEN '4+'
|
||||
ELSE '1'
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from __future__ import annotations
|
|||
|
||||
from typing import Literal
|
||||
|
||||
RoomBucket = Literal["studio", "1", "2", "3", "4+"]
|
||||
RoomBucket = Literal["studio", "euro-1", "euro-2", "1", "2", "3", "4+"]
|
||||
AreaBin = Literal["<25", "25-40", "40-60", "60-80", "80-100", "100+"]
|
||||
|
||||
|
||||
|
|
@ -15,15 +15,18 @@ def room_bucket_from_flat(
|
|||
rooms: int | None,
|
||||
flat_type: str | None,
|
||||
is_studio: bool | None,
|
||||
total_area: float | None = None,
|
||||
) -> RoomBucket:
|
||||
"""Determine room_bucket из kn_flats полей.
|
||||
|
||||
Priority:
|
||||
1. is_studio=True OR flat_type='Квартира-студия' → "studio"
|
||||
2. rooms IN (1, 2, 3) → str(rooms)
|
||||
3. rooms >= 4 → "4+"
|
||||
4. rooms = 0 (без is_studio) → "studio"
|
||||
5. fallback на "1" (rooms is None и не studio)
|
||||
2. rooms=0 (без is_studio) → "studio"
|
||||
3. Fix SF-08: rooms=2 + area<35 → "euro-1" (DOM.РФ маркирует малогабаритные как 2-комн)
|
||||
4. Fix SF-08: rooms=2 + area<50 → "euro-2" (евро-двушки 35-50м²)
|
||||
5. rooms IN (1, 2, 3) → str(rooms)
|
||||
6. rooms >= 4 → "4+"
|
||||
7. fallback на "1" (rooms is None и не studio)
|
||||
"""
|
||||
if is_studio is True or flat_type == "Квартира-студия":
|
||||
return "studio"
|
||||
|
|
@ -31,6 +34,11 @@ def room_bucket_from_flat(
|
|||
return "1"
|
||||
if rooms == 0:
|
||||
return "studio"
|
||||
if rooms == 2 and total_area is not None:
|
||||
if total_area < 35.0:
|
||||
return "euro-1"
|
||||
if total_area < 50.0:
|
||||
return "euro-2"
|
||||
if rooms >= 4:
|
||||
return "4+"
|
||||
if rooms in (1, 2, 3):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue