feat(queries/get-executions): add status filter support

This commit is contained in:
Ali BARIN
2023-10-24 20:19:52 +00:00
committed by Faruk AYDIN
parent e4eb146169
commit 2fa360e400
2 changed files with 11 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ import paginate from '../../helpers/pagination';
type Filters = {
flowId?: string;
status?: string;
}
type Params = {
@@ -19,6 +20,7 @@ const getExecutions = async (
context: Context
) => {
const conditions = context.currentUser.can('read', 'Execution');
const filters = params.filters;
const userExecutions = context.currentUser.$relatedQuery('executions');
const allExecutions = Execution.query();
@@ -46,11 +48,16 @@ const getExecutions = async (
.groupBy('executions.id')
.orderBy('updated_at', 'desc');
if (params.filters?.flowId) {
executions.where('flow_id', params.filters.flowId);
const computedExecutions = Execution.query().with('executions', executions);
if (filters?.flowId) {
computedExecutions.where('executions.flow_id', filters.flowId);
}
return paginate(executions, params.limit, params.offset);
if (filters?.status) {
computedExecutions.where('executions.status', filters.status);
}
return paginate(computedExecutions, params.limit, params.offset);
};
export default getExecutions;

View File

@@ -801,6 +801,7 @@ type Notification {
input ExecutionFiltersInput {
flowId: String
status: String
}
schema {