perf: Pool 批量删除改为异步任务模式,避免大批量删除阻塞请求

- 新增 batch_delete_task 模块,提交删除后立即返回 task_id,后台线程分批执行
- 新增查询任务进度的 API 端点,前端轮询展示实时进度
- RequestCandidate 大表清理改为按行数分批删除,防止单条语句超时
This commit is contained in:
fawney19
2026-03-09 01:35:01 +08:00
parent 0379f01ce8
commit e4476d0bc6
6 changed files with 386 additions and 80 deletions

View File

@@ -213,7 +213,7 @@ export async function listPoolKeys(
export async function batchActionPoolKeys(
providerId: string,
body: PoolBatchAction,
): Promise<{ affected: number; message: string }> {
): Promise<{ affected: number; message: string; task_id?: string }> {
const response = await client.post(
`/api/admin/pool/${providerId}/keys/batch-action`,
body,
@@ -222,6 +222,24 @@ export async function batchActionPoolKeys(
return response.data
}
export interface BatchDeleteTaskStatus {
task_id: string
status: 'pending' | 'running' | 'completed' | 'failed'
total: number
deleted: number
message: string
}
export async function getPoolBatchDeleteTask(
providerId: string,
taskId: string,
): Promise<BatchDeleteTaskStatus> {
const response = await client.get<BatchDeleteTaskStatus>(
`/api/admin/pool/${providerId}/keys/batch-delete-task/${taskId}`,
)
return response.data
}
export async function cleanupBannedPoolKeys(
providerId: string,
): Promise<{ affected: number; message: string }> {