perf(realestate): market_deals 배치 upsert(단일 conn)로 collect 속도 개선

This commit is contained in:
2026-07-10 13:50:35 +09:00
parent 8e28ce9ae5
commit b471d2c455
3 changed files with 43 additions and 5 deletions

View File

@@ -73,6 +73,22 @@ def test_upsert_market_deal_area_null_skipped():
assert cnt == 0
def test_bulk_upsert_market_deals(monkeypatch):
from app import db
rows = [
{"house_type":"아파트","dong_code":"11590","dong":"신대방동","complex_name":"OO","area":42.0,
"deal_type":"전세","deposit":43000,"sale_amount":None,"deal_ym":"202606","floor":"5"},
{"house_type":"아파트","dong_code":"11590","dong":"신대방동","complex_name":"OO","area":42.0,
"deal_type":"전세","deposit":43000,"sale_amount":None,"deal_ym":"202606","floor":"5"}, # dup
{"house_type":"아파트","dong_code":"11590","dong":None,"complex_name":None,"area":None,
"deal_type":"매매","sale_amount":90000,"deal_ym":"202606","floor":"3"}, # area None → skip
]
n = db.bulk_upsert_market_deals(rows)
assert n == 2 # area=None 1건 skip
deals = db.get_market_deals_for("11590","OO",42.0,"전세",months=120)
assert len(deals) == 1 # dup dedup → 1건
def test_get_listing_matches_json_parsed():
"""get_listing_matches()도 get_unnotified_listing_matches()와 동일하게
regulation_flags/reasons를 list로 파싱해 반환해야 한다."""