Skip to content

Commit b28c948

Browse files
committed
chore: use optimised query to get fo-each execution steps
1 parent 261a17b commit b28c948

File tree

1 file changed

+0
-46
lines changed

1 file changed

+0
-46
lines changed

packages/backend/src/models/execution-step.ts

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ class ExecutionStep extends Base {
8585
}
8686

8787
static async getForEachExecutionSteps(executionId: string) {
88-
// TESTING
8988
return ExecutionStep.query()
9089
.select('execution_steps.*', 'latest_steps.min_created_at')
9190
.with('latest_steps', (builder) => {
@@ -118,51 +117,6 @@ class ExecutionStep extends Base {
118117
})
119118
.where('execution_steps.execution_id', executionId)
120119
.orderBy('latest_steps.min_created_at', 'asc')
121-
// return ExecutionStep.query()
122-
// .with('latest_steps', (builder) => {
123-
// /**
124-
// * NOTE: there is a known issue with knex where 'groupBy' are placed at the end of the 'unionAll' query.
125-
// * the workaround is to unionAll both queries with 'true' to wrap the subequery.
126-
// */
127-
// builder
128-
// .unionAll((qb) => {
129-
// qb.select(
130-
// 'step_id',
131-
// raw('max(created_at) as max_created_at'),
132-
// raw('min(created_at) as min_created_at'),
133-
// )
134-
// .from('execution_steps')
135-
// .groupBy('step_id')
136-
// .where('execution_id', '=', executionId)
137-
// .where(raw("metadata = '{}'::jsonb"))
138-
// .withSoftDeleted()
139-
// }, true)
140-
// .unionAll((qb) => {
141-
// qb.select(
142-
// 'step_id',
143-
// raw('max(created_at) as max_created_at'),
144-
// raw('min(created_at) as min_created_at'),
145-
// )
146-
// .from('execution_steps')
147-
// .groupBy('step_id', raw("metadata->>'iteration'"))
148-
// .where('execution_id', '=', executionId)
149-
// .where(raw("metadata != '{}'::jsonb"))
150-
// .withSoftDeleted()
151-
// }, true)
152-
// .withSoftDeleted()
153-
// })
154-
// .join('latest_steps', (builder) => {
155-
// builder
156-
// .on('execution_steps.step_id', '=', 'latest_steps.step_id')
157-
// .andOn(
158-
// 'execution_steps.created_at',
159-
// '=',
160-
// 'latest_steps.max_created_at',
161-
// )
162-
// })
163-
// .select('execution_steps.*', 'min_created_at')
164-
// .withSoftDeleted()
165-
// .orderBy('min_created_at', 'asc')
166120
}
167121

168122
static async getForEachExecutionState(executionId: string) {

0 commit comments

Comments
 (0)