feat: Add dynamic status field to get executions graphQL query
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { raw } from 'objection';
|
||||||
import Context from '../../types/express/context';
|
import Context from '../../types/express/context';
|
||||||
import paginate from '../../helpers/pagination';
|
import paginate from '../../helpers/pagination';
|
||||||
|
|
||||||
@@ -11,14 +12,26 @@ const getExecutions = async (
|
|||||||
params: Params,
|
params: Params,
|
||||||
context: Context
|
context: Context
|
||||||
) => {
|
) => {
|
||||||
|
const selectStatusStatement = `
|
||||||
|
case
|
||||||
|
when count(*) filter (where execution_steps.status = 'failure') > 0
|
||||||
|
then 'failure'
|
||||||
|
else 'success'
|
||||||
|
end
|
||||||
|
as status
|
||||||
|
`;
|
||||||
|
|
||||||
const executions = context.currentUser
|
const executions = context.currentUser
|
||||||
.$relatedQuery('executions')
|
.$relatedQuery('executions')
|
||||||
|
.joinRelated('executionSteps as execution_steps')
|
||||||
|
.select('executions.*', raw(selectStatusStatement))
|
||||||
.withSoftDeleted()
|
.withSoftDeleted()
|
||||||
.withGraphFetched({
|
.withGraphFetched({
|
||||||
flow: {
|
flow: {
|
||||||
steps: true,
|
steps: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
.groupBy('executions.id')
|
||||||
.orderBy('created_at', 'desc');
|
.orderBy('created_at', 'desc');
|
||||||
|
|
||||||
return paginate(executions, params.limit, params.offset);
|
return paginate(executions, params.limit, params.offset);
|
||||||
|
@@ -233,6 +233,7 @@ type Execution {
|
|||||||
testRun: Boolean
|
testRun: Boolean
|
||||||
createdAt: String
|
createdAt: String
|
||||||
updatedAt: String
|
updatedAt: String
|
||||||
|
status: String
|
||||||
flow: Flow
|
flow: Flow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user