feat(realestate-lab): 공고 목록에 매칭 점수 포함
- _enrich_items()로 통합: 가격 범위 + match_score/reasons/eligible_types - 프로필 기반 매칭 점수가 공고 카드에 바로 표시됨 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -235,11 +235,13 @@ def upsert_announcement(data: Dict[str, Any]) -> tuple:
|
||||
return _ann_row_to_dict(row), is_new
|
||||
|
||||
|
||||
def _enrich_with_price(conn, items: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
||||
"""공고 목록에 모델 기반 가격 범위를 추가한다."""
|
||||
def _enrich_items(conn, items: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
||||
"""공고 목록에 모델 기반 가격 범위 + 매칭 점수를 추가한다."""
|
||||
for item in items:
|
||||
ann_id = item.get("id")
|
||||
hmno = item.get("house_manage_no")
|
||||
pno = item.get("pblanc_no")
|
||||
# 가격 정보
|
||||
if hmno and pno:
|
||||
price_row = conn.execute(
|
||||
"SELECT MIN(top_amount) as min_price, MAX(top_amount) as max_price "
|
||||
@@ -249,6 +251,16 @@ def _enrich_with_price(conn, items: List[Dict[str, Any]]) -> List[Dict[str, Any]
|
||||
if price_row and price_row["min_price"] is not None:
|
||||
item["min_price"] = price_row["min_price"]
|
||||
item["max_price_display"] = price_row["max_price"]
|
||||
# 매칭 점수
|
||||
if ann_id:
|
||||
match_row = conn.execute(
|
||||
"SELECT match_score, match_reasons, eligible_types FROM match_results WHERE announcement_id = ?",
|
||||
(ann_id,),
|
||||
).fetchone()
|
||||
if match_row:
|
||||
item["match_score"] = match_row["match_score"]
|
||||
item["match_reasons"] = json.loads(match_row["match_reasons"]) if match_row["match_reasons"] else []
|
||||
item["eligible_types"] = json.loads(match_row["eligible_types"]) if match_row["eligible_types"] else []
|
||||
return items
|
||||
|
||||
|
||||
@@ -296,7 +308,7 @@ def get_announcements(
|
||||
params + [size, offset],
|
||||
).fetchall()
|
||||
items = [_ann_row_to_dict(r) for r in rows]
|
||||
items = _enrich_with_price(conn, items)
|
||||
items = _enrich_items(conn, items)
|
||||
return {
|
||||
"items": items,
|
||||
"total": total,
|
||||
@@ -617,7 +629,7 @@ def get_dashboard() -> Dict[str, Any]:
|
||||
ORDER BY receipt_start ASC
|
||||
""").fetchall()
|
||||
bookmarked_items = [_ann_row_to_dict(r) for r in bookmarked_rows]
|
||||
bookmarked_items = _enrich_with_price(conn, bookmarked_items)
|
||||
bookmarked_items = _enrich_items(conn, bookmarked_items)
|
||||
|
||||
return {
|
||||
"active_count": active,
|
||||
|
||||
Reference in New Issue
Block a user