Merge pull request #2405 from automatisch/use-execution-status
feat: Use status directly from executions
This commit is contained in:
@@ -14,14 +14,5 @@ export default async (request, response) => {
|
|||||||
|
|
||||||
const executions = await paginateRest(executionsQuery, request.query.page);
|
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);
|
renderObject(response, executions);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ exports[`Execution model > jsonSchema should have correct validations 1`] = `
|
|||||||
"internalId": {
|
"internalId": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
},
|
},
|
||||||
|
"status": {
|
||||||
|
"enum": [
|
||||||
|
"success",
|
||||||
|
"failure",
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"testRun": {
|
"testRun": {
|
||||||
"default": false,
|
"default": false,
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class Execution extends Base {
|
|||||||
flowId: { type: 'string', format: 'uuid' },
|
flowId: { type: 'string', format: 'uuid' },
|
||||||
testRun: { type: 'boolean', default: false },
|
testRun: { type: 'boolean', default: false },
|
||||||
internalId: { type: 'string' },
|
internalId: { type: 'string' },
|
||||||
|
status: { type: 'string', enum: ['success', 'failure'] },
|
||||||
deletedAt: { type: 'string' },
|
deletedAt: { type: 'string' },
|
||||||
createdAt: { type: 'string' },
|
createdAt: { type: 'string' },
|
||||||
updatedAt: { type: 'string' },
|
updatedAt: { type: 'string' },
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const executionSerializer = (execution) => {
|
|||||||
let executionData = {
|
let executionData = {
|
||||||
id: execution.id,
|
id: execution.id,
|
||||||
testRun: execution.testRun,
|
testRun: execution.testRun,
|
||||||
|
status: execution.status,
|
||||||
createdAt: execution.createdAt.getTime(),
|
createdAt: execution.createdAt.getTime(),
|
||||||
updatedAt: execution.updatedAt.getTime(),
|
updatedAt: execution.updatedAt.getTime(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ describe('executionSerializer', () => {
|
|||||||
const expectedPayload = {
|
const expectedPayload = {
|
||||||
id: execution.id,
|
id: execution.id,
|
||||||
testRun: execution.testRun,
|
testRun: execution.testRun,
|
||||||
|
status: execution.status,
|
||||||
createdAt: execution.createdAt.getTime(),
|
createdAt: execution.createdAt.getTime(),
|
||||||
updatedAt: execution.updatedAt.getTime(),
|
updatedAt: execution.updatedAt.getTime(),
|
||||||
};
|
};
|
||||||
@@ -26,20 +27,6 @@ describe('executionSerializer', () => {
|
|||||||
expect(executionSerializer(execution)).toStrictEqual(expectedPayload);
|
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 () => {
|
it('should return the execution data with the flow', async () => {
|
||||||
execution.flow = flow;
|
execution.flow = flow;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { createFlow } from './flow';
|
|||||||
export const createExecution = async (params = {}) => {
|
export const createExecution = async (params = {}) => {
|
||||||
params.flowId = params?.flowId || (await createFlow()).id;
|
params.flowId = params?.flowId || (await createFlow()).id;
|
||||||
params.testRun = params?.testRun || false;
|
params.testRun = params?.testRun || false;
|
||||||
|
params.status = params?.status || 'success';
|
||||||
|
|
||||||
const execution = await Execution.query().insertAndFetch(params);
|
const execution = await Execution.query().insertAndFetch(params);
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const getExecutionMock = async (execution, flow, steps) => {
|
|||||||
const data = {
|
const data = {
|
||||||
id: execution.id,
|
id: execution.id,
|
||||||
testRun: execution.testRun,
|
testRun: execution.testRun,
|
||||||
|
status: execution.status,
|
||||||
createdAt: execution.createdAt.getTime(),
|
createdAt: execution.createdAt.getTime(),
|
||||||
updatedAt: execution.updatedAt.getTime(),
|
updatedAt: execution.updatedAt.getTime(),
|
||||||
flow: {
|
flow: {
|
||||||
|
|||||||
Reference in New Issue
Block a user