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

This commit is contained in:
Ali BARIN
2023-10-24 20:20:13 +00:00
parent ef3db21848
commit 6747c120ac
2 changed files with 23 additions and 0 deletions

View File

@@ -6,6 +6,10 @@ import paginate from '../../helpers/pagination';
type Filters = {
flowId?: string;
status?: string;
updatedAt?: {
from?: string;
to?: string;
};
}
type Params = {
@@ -20,6 +24,7 @@ const getExecutions = async (
context: Context
) => {
const conditions = context.currentUser.can('read', 'Execution');
const filters = params.filters;
const userExecutions = context.currentUser.$relatedQuery('executions');
@@ -57,6 +62,18 @@ const getExecutions = async (
if (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);
};

View File

@@ -799,8 +799,14 @@ type Notification {
description: String
}
input ExecutionUpdatedAtFilterInput {
from: String
to: String
}
input ExecutionFiltersInput {
flowId: String
updatedAt: ExecutionUpdatedAtFilterInput
status: String
}