From 496e3a6a73540b57ed235b853108c6a70731e1f6 Mon Sep 17 00:00:00 2001 From: gahusb Date: Tue, 28 Apr 2026 08:24:03 +0900 Subject: [PATCH] refactor(realestate-db): tuple param + status column in unnotified query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - mark_matches_notified: pass tuple(match_ids) to conn.execute for consistency - get_unnotified_matches: add a.status to SELECT so notifier/formatter can skip stale '완료' matches - add regression test: test_get_unnotified_matches_includes_status Co-Authored-By: Claude Sonnet 4.6 --- realestate-lab/app/db.py | 4 ++-- realestate-lab/tests/test_db_functions.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/realestate-lab/app/db.py b/realestate-lab/app/db.py index 21da0d9..dd69bd9 100644 --- a/realestate-lab/app/db.py +++ b/realestate-lab/app/db.py @@ -714,7 +714,7 @@ def get_unnotified_matches(min_score: int) -> List[Dict[str, Any]]: with _conn() as conn: rows = conn.execute(""" SELECT m.id, m.announcement_id, m.match_score, m.match_reasons, m.eligible_types, - a.house_nm, a.region_name, a.district, a.address, + a.house_nm, a.region_name, a.district, a.address, a.status, a.receipt_start, a.receipt_end, a.winner_date, a.house_secd, a.is_speculative_area, a.is_price_cap, a.pblanc_url FROM match_results m @@ -741,7 +741,7 @@ def mark_matches_notified(match_ids: List[int]) -> None: conn.execute( f"UPDATE match_results SET notified_at = strftime('%Y-%m-%dT%H:%M:%fZ','now') " f"WHERE id IN ({placeholders})", - match_ids, + tuple(match_ids), ) diff --git a/realestate-lab/tests/test_db_functions.py b/realestate-lab/tests/test_db_functions.py index 9d46ce9..0707a01 100644 --- a/realestate-lab/tests/test_db_functions.py +++ b/realestate-lab/tests/test_db_functions.py @@ -84,3 +84,17 @@ def test_mark_matches_notified_sets_timestamp(): with _conn() as conn: row = conn.execute("SELECT notified_at FROM match_results WHERE id = ?", (match_id,)).fetchone() assert row["notified_at"] is not None + + +def test_get_unnotified_matches_includes_status(): + from app.db import get_unnotified_matches + aid = _seed_announcement("StatusA", "청약중", hmno="ST", pno="1") + with _conn() as conn: + conn.execute(""" + INSERT INTO match_results (announcement_id, model_id, match_score, match_reasons, eligible_types, is_new) + VALUES (?, NULL, 80, '[]', '[]', 1) + """, (aid,)) + matches = get_unnotified_matches(min_score=70) + status_matches = [m for m in matches if m["house_nm"] == "StatusA"] + assert len(status_matches) == 1 + assert status_matches[0]["status"] == "청약중"