fix(knowledge): 草稿的过程段写「收件箱 → 待办」,而不是两句「状态变更」
CI / backend (push) Canceled after 0s

自动生成的草稿里,时间线只查了 activity.action,没带 payload,
于是每条状态变化都变成一模一样的「状态变更」,读者看不出事情怎么走的。

- services/knowledge.snapshot_source 多取 Activity.payload 一起交给渲染
- domain/knowledge 加 STATUS_LABEL 与 _describe(),把 payload 的 from/to 翻成人话
- 新增用例断言草稿里有「待办 → 进行中」「进行中 → 已完成」

66 passed。
This commit is contained in:
dadao
2026-10-28 14:14:50 +08:00
parent 07688881b4
commit 0919c8ecd3
3 changed files with 61 additions and 3 deletions
+2 -2
View File
@@ -26,7 +26,7 @@ async def snapshot_source(session: AsyncSession, ws_id: uuid.UUID, item: Item) -
)
timeline = (
await session.execute(
select(Activity.action, Activity.created_at)
select(Activity.action, Activity.created_at, Activity.payload)
.where(Activity.workspace_id == ws_id, Activity.item_id == item.id)
.order_by(Activity.created_at)
)
@@ -47,7 +47,7 @@ async def snapshot_source(session: AsyncSession, ws_id: uuid.UUID, item: Item) -
"提出人": nicknames.get(item.creator_id, ""),
"办理人": nicknames.get(item.assignee_id, "") if item.assignee_id else "",
},
"timeline": [{"action": a, "at": at} for a, at in timeline],
"timeline": [{"action": a, "at": at, "payload": p or {}} for a, at, p in timeline],
"comments": [
{"body": body, "author": nicknames.get(author_id, ""), "at": at}
for body, author_id, at in comments