refactor: migrate workflow to v2 core and archive legacy modules

This commit is contained in:
2026-03-04 21:52:24 +08:00
parent e1ce17f2aa
commit fa61b11b02
156 changed files with 1781 additions and 2066 deletions

View File

@@ -199,14 +199,18 @@ def get_customers(limit: int = 100) -> List[Dict]:
def get_conversation(customer_id: str, limit: int = 200) -> List[Dict]:
"""返回某客户的全部对话记录(按时间升序)"""
"""返回某客户的最近对话记录(按时间升序)"""
with _get_conn() as conn:
# 核心修复:先取最新的 limit 条,再按时间正序排列
rows = conn.execute(_sql("""
SELECT id, direction, message, msg_type, timestamp, acc_id
FROM chat_logs
WHERE customer_id = ?
SELECT * FROM (
SELECT id, direction, message, msg_type, timestamp, acc_id
FROM chat_logs
WHERE customer_id = ?
ORDER BY timestamp DESC, id DESC
LIMIT ?
) AS recent
ORDER BY timestamp ASC, id ASC
LIMIT ?
"""), (customer_id, limit)).fetchall()
return [dict(r) for r in rows]