feat(queries/get-executions): add updatedAt filter support
This commit is contained in:
@@ -6,6 +6,10 @@ import paginate from '../../helpers/pagination';
|
|||||||
type Filters = {
|
type Filters = {
|
||||||
flowId?: string;
|
flowId?: string;
|
||||||
status?: string;
|
status?: string;
|
||||||
|
updatedAt?: {
|
||||||
|
from?: string;
|
||||||
|
to?: string;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
@@ -20,6 +24,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 filters = params.filters;
|
||||||
|
|
||||||
const userExecutions = context.currentUser.$relatedQuery('executions');
|
const userExecutions = context.currentUser.$relatedQuery('executions');
|
||||||
@@ -57,6 +62,18 @@ const getExecutions = async (
|
|||||||
if (filters?.status) {
|
if (filters?.status) {
|
||||||
computedExecutions.where('executions.status', filters.status);
|
computedExecutions.where('executions.status', filters.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filters?.updatedAt) {
|
||||||
|
const updatedAtFilter = filters.updatedAt;
|
||||||
|
if (updatedAtFilter.from) {
|
||||||
|
computedExecutions.where('executions.updated_at', '>=', updatedAtFilter.from);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updatedAtFilter.to) {
|
||||||
|
computedExecutions.where('executions.updated_at', '<=', updatedAtFilter.to);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return paginate(computedExecutions, params.limit, params.offset);
|
return paginate(computedExecutions, params.limit, params.offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -799,8 +799,14 @@ type Notification {
|
|||||||
description: String
|
description: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input ExecutionUpdatedAtFilterInput {
|
||||||
|
from: String
|
||||||
|
to: String
|
||||||
|
}
|
||||||
|
|
||||||
input ExecutionFiltersInput {
|
input ExecutionFiltersInput {
|
||||||
flowId: String
|
flowId: String
|
||||||
|
updatedAt: ExecutionUpdatedAtFilterInput
|
||||||
status: String
|
status: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user