fix: Adjust get step with test executions SQL query

This commit is contained in:
Faruk AYDIN
2022-09-23 03:08:51 +03:00
committed by Ali BARIN
parent 90f4c873bb
commit 7e960024dd

View File

@@ -16,14 +16,13 @@ const getStepWithTestExecutions = async (
const previousStepsWithCurrentStep = await context.currentUser
.$relatedQuery('steps')
.withGraphJoined('executionSteps')
.withGraphFetched('executionSteps')
.modifyGraph('executionSteps', (builder) => {
builder.orderBy('created_at', 'desc').limit(1);
})
.where('flow_id', '=', step.flowId)
.andWhere('position', '<', step.position)
.distinctOn('executionSteps.step_id')
.orderBy([
'executionSteps.step_id',
{ column: 'executionSteps.created_at', order: 'desc' },
]);
.orderBy('steps.position', 'asc');
return previousStepsWithCurrentStep;
};