feat: 定时任务运行详情执行过程视图 + 管理员下载删除 + MySQL 迁移修复
定时任务:
- 运行详情页新增「执行过程」标签页,按 agent_run_id 拉取该次运行的
agent 消息(GET /scheduled-tasks/runs/{id}/messages),运行中每 4s
自动刷新,可观察卡住的任务停在哪一步
- 详情页「返回」按钮回到来源列表(普通/管理员)并重新选中原任务
- 管理员可下载、删除任意用户的执行记录(DELETE /runs/{id} 加管理员兜底)
MySQL 兼容修复:
- 合并迁移 20260518_06 汇合 ai-writing 与 thread-shares 两个 head
- 20260517_02 改用 SQLAlchemy Core 构造,规避保留字 key 的 1064 报错
- list_messages_by_run 各事件存储补 user_id 形参以保持接口一致
测试: 新增 test_scheduled_task_admin_run_delete.py
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
449703a6f0
commit
e3cde9be25
18 files changed
+534
-57
No files matched your search
+17
-1
@@ -234,6 +234,15 @@ class ScheduledTaskRepository(ScheduledTaskStore):
|
||||
await session.commit()
|
||||
return True
|
||||
|
||||
async def delete_run_any(self, run_id: str) -> bool:
|
||||
async with self._sf() as session:
|
||||
row = await session.get(ScheduledTaskRunRow, run_id)
|
||||
if row is None:
|
||||
return False
|
||||
await session.delete(row)
|
||||
await session.commit()
|
||||
return True
|
||||
|
||||
async def get_delivery_profile(self, user_id: str) -> dict[str, Any]:
|
||||
async with self._sf() as session:
|
||||
row = await session.get(ScheduledTaskDeliveryProfileRow, user_id)
|
||||
@@ -286,7 +295,14 @@ class ScheduledTaskRepository(ScheduledTaskStore):
|
||||
result = await session.execute(
|
||||
select(ScheduledTaskRow)
|
||||
.where(ScheduledTaskRow.published.is_(True))
|
||||
.order_by(ScheduledTaskRow.published_at.desc().nullslast(), ScheduledTaskRow.created_at.desc())
|
||||
# ``NULLS LAST`` is unsupported by MySQL — sort by an
|
||||
# ``IS NULL`` flag instead (False<True ⇒ non-null rows first),
|
||||
# which is portable across mysql/sqlite/postgres.
|
||||
.order_by(
|
||||
ScheduledTaskRow.published_at.is_(None),
|
||||
ScheduledTaskRow.published_at.desc(),
|
||||
ScheduledTaskRow.created_at.desc(),
|
||||
)
|
||||
.offset(max(0, offset))
|
||||
.limit(max(1, limit))
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user