Merge pull request #1766 from automatisch/AUT-705

refactor: rewrite useStepWithTestExecutions with RQ
This commit is contained in:
Ali BARIN
2024-04-10 13:30:04 +02:00
committed by GitHub
8 changed files with 32 additions and 83 deletions

View File

@@ -1,34 +0,0 @@
import { ref } from 'objection';
import ExecutionStep from '../../models/execution-step.js';
import Step from '../../models/step.js';
const getStepWithTestExecutions = async (_parent, params, context) => {
const conditions = context.currentUser.can('update', 'Flow');
const userSteps = context.currentUser.$relatedQuery('steps');
const allSteps = Step.query();
const stepBaseQuery = conditions.isCreator ? userSteps : allSteps;
const step = await stepBaseQuery
.clone()
.findOne({ 'steps.id': params.stepId })
.throwIfNotFound();
const previousStepsWithCurrentStep = await stepBaseQuery
.clone()
.withGraphJoined('executionSteps')
.where('flow_id', '=', step.flowId)
.andWhere('position', '<', step.position)
.andWhere(
'executionSteps.created_at',
'=',
ExecutionStep.query()
.max('created_at')
.where('step_id', '=', ref('steps.id'))
.andWhere('status', 'success')
)
.orderBy('steps.position', 'asc');
return previousStepsWithCurrentStep;
};
export default getStepWithTestExecutions;

View File

@@ -1,14 +1,12 @@
import getAppAuthClient from './queries/get-app-auth-client.ee.js';
import getConnectedApps from './queries/get-connected-apps.js';
import getDynamicData from './queries/get-dynamic-data.js';
import getStepWithTestExecutions from './queries/get-step-with-test-executions.js';
import testConnection from './queries/test-connection.js';
const queryResolvers = {
getAppAuthClient,
getConnectedApps,
getDynamicData,
getStepWithTestExecutions,
testConnection,
};

View File

@@ -2,7 +2,6 @@ type Query {
getAppAuthClient(id: String!): AppAuthClient
getConnectedApps(name: String): [App]
testConnection(id: String!): Connection
getStepWithTestExecutions(stepId: String!): [Step]
getDynamicData(
stepId: String!
key: String!