perf(realestate): run_listing_matching 단일 conn+배치 + POST /listings/rematch(MOLIT없이 즉시 재판정)
- get_market_deals_for에 optional conn 파라미터 추가(재사용 시 open/close 안 함, 기존 단건 호출부는 불변) - bulk_upsert_listing_matches 추가(listing_matches 다건 upsert, 단일 connection) - run_listing_matching이 listings 조회+매물별 market_deals 조회+최종 upsert를 단일 _conn()으로 처리 (기존: 269건 매물마다 개별 _conn() 3회 → 병목) - POST /api/realestate/listings/rematch: MOLIT 재수집 없이 기존 listings+market_deals로 즉시 재판정 (알림 미발송, 즉시 피드백용) 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:
@@ -31,3 +31,28 @@ def test_safety_check_rent():
|
||||
|
||||
def test_listings_collect_status():
|
||||
assert _client().get("/api/realestate/listings/collect/status").status_code == 200
|
||||
|
||||
|
||||
def test_listings_rematch_endpoint():
|
||||
"""MOLIT 재수집 없이 기존 listings+market_deals로 즉시 재판정 — 200 + 요약 카운트."""
|
||||
from app import db
|
||||
for i, v in enumerate((40000, 42000, 44000)):
|
||||
db.upsert_market_deal({"house_type": "아파트", "dong_code": "11590", "dong": "신대방동",
|
||||
"complex_name": "OO", "area": 42.0, "deal_type": "전세",
|
||||
"deposit": v, "sale_amount": None,
|
||||
"deal_ym": f"2026{i+1:02d}", "floor": "5", "source": "molit"})
|
||||
db.upsert_listing({"article_no": "RM1", "source": "naver", "deal_type": "전세",
|
||||
"deposit": 28000, "area_exclusive": 42.0, "complex_name": "OO",
|
||||
"dong": "신대방동", "dong_code": "11590"})
|
||||
db.update_listing_criteria({"dongs": ["신대방동"], "deal_types": ["전세"], "max_deposit": 32000,
|
||||
"min_area": 40.0, "house_types": ["아파트"]})
|
||||
|
||||
r = _client().post("/api/realestate/listings/rematch")
|
||||
assert r.status_code == 200
|
||||
body = r.json()
|
||||
assert body["total"] == 1
|
||||
assert body["passed"] == 1
|
||||
assert body["judged"] == 1
|
||||
|
||||
matches = db.get_listing_matches()
|
||||
assert matches[0]["safety_tier"] == "안전"
|
||||
|
||||
Reference in New Issue
Block a user