fix(realestate): 네이버 매물 dong_code를 dong명에서 유도(cortarNo 부재)→ market_deals 매칭·판정 복구
네이버 article에 cortarNo가 없는 경우 listing.dong_code가 None으로 저장되어 get_market_deals_for가 시세를 못 찾아 모든 매물이 '보류'(판정 불가) 상태였다. dong명은 항상 정확히 태깅되므로 lawd_code(dong)으로 5자리 시군구코드를 유도해 market_deals와 매칭시킨다. - internal_router.listings_ingest: dong_code 없으면 batch.dong에서 lawd_code로 보정 - db.upsert_listing: ON CONFLICT UPDATE SET에 dong_code 추가(재유입 시 기존 None행 갱신) - listing_matcher.run_listing_matching: get_market_deals_for 호출 전 dong_code 없으면 listing.dong에서 즉시 유도(기존 저장된 None행도 재실행만으로 판정 복구) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EqCYBhvTcdeCTUDX3RhWx9
This commit is contained in:
@@ -77,3 +77,35 @@ def test_run_listing_matching_end_to_end_safe_rent_and_overpriced_sale():
|
||||
sale_m = matches[l_sale["id"]]
|
||||
assert sale_m["valuation_tier"] == "고가"
|
||||
assert sale_m["sample_size"] == 4
|
||||
|
||||
|
||||
# ── 근본원인 fix: 기존 저장된 listing.dong_code=None(cortarNo 부재) 행도 dong명에서
|
||||
# lawd_code를 유도해 즉시 판정돼야 한다(보류 고착 방지) ──
|
||||
|
||||
def test_run_listing_matching_derives_dong_code_when_none():
|
||||
from app import db
|
||||
from app.listing_matcher import run_listing_matching
|
||||
|
||||
db.update_listing_criteria({
|
||||
"dongs": ["신길동"], "deal_types": ["매매"],
|
||||
"min_area": 40.0, "house_types": ["아파트"],
|
||||
"equity": 20000, "annual_income": 6000,
|
||||
})
|
||||
|
||||
# 신길동(영등포구=11560) 매매 실거래 시세 3건
|
||||
for i, v in enumerate((80000, 88000, 90000)):
|
||||
db.upsert_market_deal({"house_type": "아파트", "dong_code": "11560", "dong": "신길동",
|
||||
"complex_name": "QQ", "area": 59.0, "deal_type": "매매",
|
||||
"deposit": None, "sale_amount": v,
|
||||
"deal_ym": f"2026{i+1:02d}", "floor": "8", "source": "molit"})
|
||||
# 매물은 dong_code=None으로 저장(네이버 cortarNo 부재 시나리오)
|
||||
l_sale, _ = db.upsert_listing({"article_no": "R3", "source": "naver", "deal_type": "매매",
|
||||
"sale_price": 84000, "area_exclusive": 59.0,
|
||||
"complex_name": "QQ", "dong": "신길동", "dong_code": None})
|
||||
|
||||
run_listing_matching()
|
||||
|
||||
matches = {m["listing_id"]: m for m in db.get_listing_matches()}
|
||||
m = matches[l_sale["id"]]
|
||||
assert m["sample_size"] == 3
|
||||
assert m["valuation_tier"] != "보류"
|
||||
|
||||
Reference in New Issue
Block a user