From 7e960024ddff0c5ecbdfac9197bb031fce4d06a9 Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Fri, 23 Sep 2022 03:08:51 +0300 Subject: [PATCH] fix: Adjust get step with test executions SQL query --- .../graphql/queries/get-step-with-test-executions.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/graphql/queries/get-step-with-test-executions.ts b/packages/backend/src/graphql/queries/get-step-with-test-executions.ts index 9030195b..ff7b93ea 100644 --- a/packages/backend/src/graphql/queries/get-step-with-test-executions.ts +++ b/packages/backend/src/graphql/queries/get-step-with-test-executions.ts @@ -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; };