重构物流客服模块并完善会话接待工作台
- 拆分应用工厂、业务服务与路由,保留原有 HTTP/SSE 和存储入口 - 分离页面资源,重排客服工作台并完善响应式导航、草稿和附件交互 - 整理维护脚本、请求示例和贡献指南,移除启动脚本中的密钥配置 - 上传文件改为仅本地保留,补充隔离的后端与前端回归验证 验证:46 项 Python 测试通过,含 14 个已有子测试;12 个 Node 前端场景通过。
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
"""Close all active human sessions; waiting sessions and messages are preserved."""
|
||||
|
||||
import argparse
|
||||
import sqlite3
|
||||
from contextlib import closing
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
DEFAULT_DB = Path(__file__).resolve().parents[1] / "history.db"
|
||||
|
||||
|
||||
def close_active_sessions(db_path=None):
|
||||
database = Path(db_path if db_path is not None else DEFAULT_DB).expanduser().resolve()
|
||||
with closing(sqlite3.connect(database.as_uri() + "?mode=rw", uri=True)) as connection:
|
||||
with connection:
|
||||
count = connection.execute(
|
||||
"UPDATE human_sessions SET status='closed' WHERE status='active'"
|
||||
).rowcount
|
||||
return count
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--db", type=Path, default=DEFAULT_DB, help="Existing SQLite database")
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
count = close_active_sessions(args.db)
|
||||
except sqlite3.Error as error:
|
||||
parser.exit(1, f"Database error: {error}\n")
|
||||
print(f"Closed {count} active session(s).")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Inspect recent human messages and open sessions without changing the database."""
|
||||
|
||||
import argparse
|
||||
import sqlite3
|
||||
from contextlib import closing
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
DEFAULT_DB = Path(__file__).resolve().parents[1] / "history.db"
|
||||
|
||||
|
||||
def inspect_sessions(db_path=None):
|
||||
database = Path(db_path if db_path is not None else DEFAULT_DB).expanduser().resolve()
|
||||
with closing(sqlite3.connect(database.as_uri() + "?mode=ro", uri=True)) as connection:
|
||||
messages = connection.execute(
|
||||
"SELECT * FROM human_messages ORDER BY id DESC LIMIT 5"
|
||||
).fetchall()
|
||||
sessions = connection.execute(
|
||||
"SELECT id, status FROM human_sessions WHERE status!='closed' ORDER BY id"
|
||||
).fetchall()
|
||||
return messages, sessions
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--db", type=Path, default=DEFAULT_DB, help="Existing SQLite database")
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
messages, sessions = inspect_sessions(args.db)
|
||||
except sqlite3.Error as error:
|
||||
parser.exit(1, f"Database error: {error}\n")
|
||||
print(messages)
|
||||
print("---")
|
||||
print(sessions)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user