Skip to content

Commit 42fed57

Browse files
feat: execution filter by agentflow name (#5117)
* feat: Add agentflow name filter to executions page - Add agentflow name text field to executions filter UI - Implement backend filtering with case-insensitive partial matching - Add database index on chat_flow.name for improved query performance - Support filtering executions by agentflow name across all database types * chore: Fix linting issues and remove screenshot - Apply prettier formatting to migration files - Fix formatting in executions service - Remove accidentally committed screenshot file
1 parent 449e811 commit 42fed57

File tree

11 files changed

+87
-6
lines changed

11 files changed

+87
-6
lines changed

packages/server/src/controllers/executions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const getAllExecutions = async (req: Request, res: Response, next: NextFunction)
4747

4848
// Flow and session filters
4949
if (req.query.agentflowId) filters.agentflowId = req.query.agentflowId as string
50+
if (req.query.agentflowName) filters.agentflowName = req.query.agentflowName as string
5051
if (req.query.sessionId) filters.sessionId = req.query.sessionId as string
5152

5253
// State filter
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm'
2+
3+
export class AddChatFlowNameIndex1755748356008 implements MigrationInterface {
4+
name = 'AddChatFlowNameIndex1755748356008'
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`CREATE INDEX \`IDX_chatflow_name\` ON \`chat_flow\` (\`name\`)`)
8+
}
9+
10+
public async down(queryRunner: QueryRunner): Promise<void> {
11+
await queryRunner.query(`DROP INDEX \`IDX_chatflow_name\` ON \`chat_flow\``)
12+
}
13+
}

packages/server/src/database/migrations/mariadb/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { FixOpenSourceAssistantTable1743758056188 } from './1743758056188-FixOpe
3737
import { AddErrorToEvaluationRun1744964560174 } from './1744964560174-AddErrorToEvaluationRun'
3838
import { ModifyExecutionDataColumnType1747902489801 } from './1747902489801-ModifyExecutionDataColumnType'
3939
import { ModifyChatflowType1755066758601 } from './1755066758601-ModifyChatflowType'
40+
import { AddChatFlowNameIndex1755748356008 } from './1755748356008-AddChatFlowNameIndex'
4041

4142
import { AddAuthTables1720230151482 } from '../../../enterprise/database/migrations/mariadb/1720230151482-AddAuthTables'
4243
import { AddWorkspace1725437498242 } from '../../../enterprise/database/migrations/mariadb/1725437498242-AddWorkspace'
@@ -100,5 +101,6 @@ export const mariadbMigrations = [
100101
AddErrorToEvaluationRun1744964560174,
101102
ExecutionLinkWorkspaceId1746862866554,
102103
ModifyExecutionDataColumnType1747902489801,
103-
ModifyChatflowType1755066758601
104+
ModifyChatflowType1755066758601,
105+
AddChatFlowNameIndex1755748356008
104106
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm'
2+
3+
export class AddChatFlowNameIndex1755748356008 implements MigrationInterface {
4+
name = 'AddChatFlowNameIndex1755748356008'
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`CREATE INDEX \`IDX_chatflow_name\` ON \`chat_flow\` (\`name\`)`)
8+
}
9+
10+
public async down(queryRunner: QueryRunner): Promise<void> {
11+
await queryRunner.query(`DROP INDEX \`IDX_chatflow_name\` ON \`chat_flow\``)
12+
}
13+
}

packages/server/src/database/migrations/mysql/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { AddErrorToEvaluationRun1744964560174 } from './1744964560174-AddErrorTo
3838
import { FixErrorsColumnInEvaluationRun1746437114935 } from './1746437114935-FixErrorsColumnInEvaluationRun'
3939
import { ModifyExecutionDataColumnType1747902489801 } from './1747902489801-ModifyExecutionDataColumnType'
4040
import { ModifyChatflowType1755066758601 } from './1755066758601-ModifyChatflowType'
41+
import { AddChatFlowNameIndex1755748356008 } from './1755748356008-AddChatFlowNameIndex'
4142

4243
import { AddAuthTables1720230151482 } from '../../../enterprise/database/migrations/mysql/1720230151482-AddAuthTables'
4344
import { AddWorkspace1720230151484 } from '../../../enterprise/database/migrations/mysql/1720230151484-AddWorkspace'
@@ -102,5 +103,6 @@ export const mysqlMigrations = [
102103
FixErrorsColumnInEvaluationRun1746437114935,
103104
ExecutionLinkWorkspaceId1746862866554,
104105
ModifyExecutionDataColumnType1747902489801,
105-
ModifyChatflowType1755066758601
106+
ModifyChatflowType1755066758601,
107+
AddChatFlowNameIndex1755748356008
106108
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm'
2+
3+
export class AddChatFlowNameIndex1755748356008 implements MigrationInterface {
4+
name = 'AddChatFlowNameIndex1755748356008'
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`CREATE INDEX "IDX_chatflow_name" ON "chat_flow" ("name")`)
8+
}
9+
10+
public async down(queryRunner: QueryRunner): Promise<void> {
11+
await queryRunner.query(`DROP INDEX "IDX_chatflow_name"`)
12+
}
13+
}

packages/server/src/database/migrations/postgres/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { FixOpenSourceAssistantTable1743758056188 } from './1743758056188-FixOpe
3737
import { AddErrorToEvaluationRun1744964560174 } from './1744964560174-AddErrorToEvaluationRun'
3838
import { ModifyExecutionSessionIdFieldType1748450230238 } from './1748450230238-ModifyExecutionSessionIdFieldType'
3939
import { ModifyChatflowType1755066758601 } from './1755066758601-ModifyChatflowType'
40+
import { AddChatFlowNameIndex1755748356008 } from './1755748356008-AddChatFlowNameIndex'
4041

4142
import { AddAuthTables1720230151482 } from '../../../enterprise/database/migrations/postgres/1720230151482-AddAuthTables'
4243
import { AddWorkspace1720230151484 } from '../../../enterprise/database/migrations/postgres/1720230151484-AddWorkspace'
@@ -100,5 +101,6 @@ export const postgresMigrations = [
100101
AddErrorToEvaluationRun1744964560174,
101102
ExecutionLinkWorkspaceId1746862866554,
102103
ModifyExecutionSessionIdFieldType1748450230238,
103-
ModifyChatflowType1755066758601
104+
ModifyChatflowType1755066758601,
105+
AddChatFlowNameIndex1755748356008
104106
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm'
2+
3+
export class AddChatFlowNameIndex1755748356008 implements MigrationInterface {
4+
name = 'AddChatFlowNameIndex1755748356008'
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`CREATE INDEX "IDX_chatflow_name" ON "chat_flow" ("name")`)
8+
}
9+
10+
public async down(queryRunner: QueryRunner): Promise<void> {
11+
await queryRunner.query(`DROP INDEX "IDX_chatflow_name"`)
12+
}
13+
}

packages/server/src/database/migrations/sqlite/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { AddExecutionEntity1738090872625 } from './1738090872625-AddExecutionEnt
3535
import { FixOpenSourceAssistantTable1743758056188 } from './1743758056188-FixOpenSourceAssistantTable'
3636
import { AddErrorToEvaluationRun1744964560174 } from './1744964560174-AddErrorToEvaluationRun'
3737
import { ModifyChatflowType1755066758601 } from './1755066758601-ModifyChatflowType'
38+
import { AddChatFlowNameIndex1755748356008 } from './1755748356008-AddChatFlowNameIndex'
3839

3940
import { AddAuthTables1720230151482 } from '../../../enterprise/database/migrations/sqlite/1720230151482-AddAuthTables'
4041
import { AddWorkspace1720230151484 } from '../../../enterprise/database/migrations/sqlite/1720230151484-AddWorkspace'
@@ -96,5 +97,6 @@ export const sqliteMigrations = [
9697
FixOpenSourceAssistantTable1743758056188,
9798
AddErrorToEvaluationRun1744964560174,
9899
ExecutionLinkWorkspaceId1746862866554,
99-
ModifyChatflowType1755066758601
100+
ModifyChatflowType1755066758601,
101+
AddChatFlowNameIndex1755748356008
100102
]

packages/server/src/services/executions/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
1111
export interface ExecutionFilters {
1212
id?: string
1313
agentflowId?: string
14+
agentflowName?: string
1415
sessionId?: string
1516
state?: ExecutionState
1617
startDate?: Date
@@ -65,7 +66,7 @@ const getPublicExecutionById = async (executionId: string): Promise<Execution |
6566
const getAllExecutions = async (filters: ExecutionFilters = {}): Promise<{ data: Execution[]; total: number }> => {
6667
try {
6768
const appServer = getRunningExpressApp()
68-
const { id, agentflowId, sessionId, state, startDate, endDate, page = 1, limit = 12, workspaceId } = filters
69+
const { id, agentflowId, agentflowName, sessionId, state, startDate, endDate, page = 1, limit = 12, workspaceId } = filters
6970

7071
// Handle UUID fields properly using raw parameters to avoid type conversion issues
7172
// This uses the query builder instead of direct objects for compatibility with UUID fields
@@ -78,6 +79,8 @@ const getAllExecutions = async (filters: ExecutionFilters = {}): Promise<{ data:
7879

7980
if (id) queryBuilder.andWhere('execution.id = :id', { id })
8081
if (agentflowId) queryBuilder.andWhere('execution.agentflowId = :agentflowId', { agentflowId })
82+
if (agentflowName)
83+
queryBuilder.andWhere('LOWER(agentflow.name) LIKE LOWER(:agentflowName)', { agentflowName: `%${agentflowName}%` })
8184
if (sessionId) queryBuilder.andWhere('execution.sessionId = :sessionId', { sessionId })
8285
if (state) queryBuilder.andWhere('execution.state = :state', { state })
8386
if (workspaceId) queryBuilder.andWhere('execution.workspaceId = :workspaceId', { workspaceId })

0 commit comments

Comments
 (0)