refactor(realestate-db): tuple param + status column in unnotified query
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -714,7 +714,7 @@ def get_unnotified_matches(min_score: int) -> List[Dict[str, Any]]:
|
|||||||
with _conn() as conn:
|
with _conn() as conn:
|
||||||
rows = conn.execute("""
|
rows = conn.execute("""
|
||||||
SELECT m.id, m.announcement_id, m.match_score, m.match_reasons, m.eligible_types,
|
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.receipt_start, a.receipt_end, a.winner_date,
|
||||||
a.house_secd, a.is_speculative_area, a.is_price_cap, a.pblanc_url
|
a.house_secd, a.is_speculative_area, a.is_price_cap, a.pblanc_url
|
||||||
FROM match_results m
|
FROM match_results m
|
||||||
@@ -741,7 +741,7 @@ def mark_matches_notified(match_ids: List[int]) -> None:
|
|||||||
conn.execute(
|
conn.execute(
|
||||||
f"UPDATE match_results SET notified_at = strftime('%Y-%m-%dT%H:%M:%fZ','now') "
|
f"UPDATE match_results SET notified_at = strftime('%Y-%m-%dT%H:%M:%fZ','now') "
|
||||||
f"WHERE id IN ({placeholders})",
|
f"WHERE id IN ({placeholders})",
|
||||||
match_ids,
|
tuple(match_ids),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -84,3 +84,17 @@ def test_mark_matches_notified_sets_timestamp():
|
|||||||
with _conn() as conn:
|
with _conn() as conn:
|
||||||
row = conn.execute("SELECT notified_at FROM match_results WHERE id = ?", (match_id,)).fetchone()
|
row = conn.execute("SELECT notified_at FROM match_results WHERE id = ?", (match_id,)).fetchone()
|
||||||
assert row["notified_at"] is not None
|
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"] == "청약중"
|
||||||
|
|||||||
Reference in New Issue
Block a user