Merge pull request #2405 from automatisch/use-execution-status

feat: Use status directly from executions
This commit is contained in:
Ömer Faruk Aydın
2025-03-19 20:03:42 +01:00
committed by GitHub
7 changed files with 12 additions and 23 deletions

View File

@@ -14,14 +14,5 @@ export default async (request, response) => {
const executions = await paginateRest(executionsQuery, request.query.page);
for (const execution of executions.records) {
const executionSteps = await execution.$relatedQuery('executionSteps');
const status = executionSteps.some((step) => step.status === 'failure')
? 'failure'
: 'success';
execution.status = status;
}
renderObject(response, executions);
};

View File

@@ -20,6 +20,13 @@ exports[`Execution model > jsonSchema should have correct validations 1`] = `
"internalId": {
"type": "string",
},
"status": {
"enum": [
"success",
"failure",
],
"type": "string",
},
"testRun": {
"default": false,
"type": "boolean",

View File

@@ -14,6 +14,7 @@ class Execution extends Base {
flowId: { type: 'string', format: 'uuid' },
testRun: { type: 'boolean', default: false },
internalId: { type: 'string' },
status: { type: 'string', enum: ['success', 'failure'] },
deletedAt: { type: 'string' },
createdAt: { type: 'string' },
updatedAt: { type: 'string' },

View File

@@ -4,6 +4,7 @@ const executionSerializer = (execution) => {
let executionData = {
id: execution.id,
testRun: execution.testRun,
status: execution.status,
createdAt: execution.createdAt.getTime(),
updatedAt: execution.updatedAt.getTime(),
};

View File

@@ -19,6 +19,7 @@ describe('executionSerializer', () => {
const expectedPayload = {
id: execution.id,
testRun: execution.testRun,
status: execution.status,
createdAt: execution.createdAt.getTime(),
updatedAt: execution.updatedAt.getTime(),
};
@@ -26,20 +27,6 @@ describe('executionSerializer', () => {
expect(executionSerializer(execution)).toStrictEqual(expectedPayload);
});
it('should return the execution data with status', async () => {
execution.status = 'success';
const expectedPayload = {
id: execution.id,
testRun: execution.testRun,
createdAt: execution.createdAt.getTime(),
updatedAt: execution.updatedAt.getTime(),
status: 'success',
};
expect(executionSerializer(execution)).toStrictEqual(expectedPayload);
});
it('should return the execution data with the flow', async () => {
execution.flow = flow;

View File

@@ -4,6 +4,7 @@ import { createFlow } from './flow';
export const createExecution = async (params = {}) => {
params.flowId = params?.flowId || (await createFlow()).id;
params.testRun = params?.testRun || false;
params.status = params?.status || 'success';
const execution = await Execution.query().insertAndFetch(params);

View File

@@ -2,6 +2,7 @@ const getExecutionMock = async (execution, flow, steps) => {
const data = {
id: execution.id,
testRun: execution.testRun,
status: execution.status,
createdAt: execution.createdAt.getTime(),
updatedAt: execution.updatedAt.getTime(),
flow: {