refactor: migrate workflow to v2 core and archive legacy modules
This commit is contained in:
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user