feat(queries/get-executions): add status filter support
This commit is contained in:
@@ -5,6 +5,7 @@ import paginate from '../../helpers/pagination';
|
|||||||
|
|
||||||
type Filters = {
|
type Filters = {
|
||||||
flowId?: string;
|
flowId?: string;
|
||||||
|
status?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
@@ -19,6 +20,7 @@ const getExecutions = async (
|
|||||||
context: Context
|
context: Context
|
||||||
) => {
|
) => {
|
||||||
const conditions = context.currentUser.can('read', 'Execution');
|
const conditions = context.currentUser.can('read', 'Execution');
|
||||||
|
const filters = params.filters;
|
||||||
|
|
||||||
const userExecutions = context.currentUser.$relatedQuery('executions');
|
const userExecutions = context.currentUser.$relatedQuery('executions');
|
||||||
const allExecutions = Execution.query();
|
const allExecutions = Execution.query();
|
||||||
@@ -46,11 +48,16 @@ const getExecutions = async (
|
|||||||
.groupBy('executions.id')
|
.groupBy('executions.id')
|
||||||
.orderBy('updated_at', 'desc');
|
.orderBy('updated_at', 'desc');
|
||||||
|
|
||||||
if (params.filters?.flowId) {
|
const computedExecutions = Execution.query().with('executions', executions);
|
||||||
executions.where('flow_id', params.filters.flowId);
|
|
||||||
|
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;
|
export default getExecutions;
|
||||||
|
@@ -801,6 +801,7 @@ type Notification {
|
|||||||
|
|
||||||
input ExecutionFiltersInput {
|
input ExecutionFiltersInput {
|
||||||
flowId: String
|
flowId: String
|
||||||
|
status: String
|
||||||
}
|
}
|
||||||
|
|
||||||
schema {
|
schema {
|
||||||
|
Reference in New Issue
Block a user