mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 18:09:25 +00:00
perf(agent): optimize active task lookup using indexed sessionId column
This commit is contained in:
@@ -186,17 +186,14 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
id: teamId,
|
||||
})
|
||||
|
||||
const activeTasks = await prisma.workflowTask.findMany({
|
||||
const taskToAbort = await prisma.workflowTask.findFirst({
|
||||
where: {
|
||||
status: { in: ['pending', 'processing'] },
|
||||
type: 'chat',
|
||||
sessionId,
|
||||
},
|
||||
})
|
||||
|
||||
const taskToAbort = activeTasks.find(
|
||||
(t) => (t.payload as PrismaJson.WorkflowTaskPayload)?.agent?.sessionId === sessionId,
|
||||
)
|
||||
|
||||
if (!taskToAbort) {
|
||||
return c.json({ error: 'No active execution found for this session' }, 404)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user