优化首页统计和任务请求
This commit is contained in:
@@ -1384,12 +1384,6 @@ def list_tasks(
|
||||
current: User = Depends(require_permission("huya:task")),
|
||||
):
|
||||
"""查看虎牙任务记录。"""
|
||||
cleanup_orphan_huya_tasks(
|
||||
db,
|
||||
active_batch_ids=huya_batch_registry.active_ids(),
|
||||
statuses=("pending", "running"),
|
||||
message="任务已中断(无执行器接管)",
|
||||
)
|
||||
query = _visible_huya_tasks_query(db, current)
|
||||
if batch_id:
|
||||
query = query.filter(HuyaTask.batch_id == batch_id)
|
||||
@@ -1397,6 +1391,21 @@ def list_tasks(
|
||||
return [_task_out(task, include_images=include_images) for task in tasks]
|
||||
|
||||
|
||||
@router.post("/tasks/cleanup-orphans")
|
||||
def cleanup_orphan_tasks(
|
||||
db: Session = Depends(get_db),
|
||||
current: User = Depends(require_permission("huya:task")),
|
||||
):
|
||||
"""手动清理没有内存执行器接管的虎牙任务。"""
|
||||
cleaned = cleanup_orphan_huya_tasks(
|
||||
db,
|
||||
active_batch_ids=huya_batch_registry.active_ids(),
|
||||
statuses=("pending", "running"),
|
||||
message="任务已中断(无执行器接管)",
|
||||
)
|
||||
return {"message": f"已清理 {cleaned} 个残留任务", "cleaned": cleaned, "success": True}
|
||||
|
||||
|
||||
@router.get("/tasks/summary")
|
||||
def tasks_summary(
|
||||
db: Session = Depends(get_db),
|
||||
|
||||
Reference in New Issue
Block a user