From 1b21bbe5b79ee935c04a470ead49e7ae92e21ae6 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Wed, 25 Oct 2023 10:32:28 +0000 Subject: [PATCH] feat(queries/get-executions): accept timestamp instead of ISO datetime --- .../backend/src/graphql/queries/get-executions.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/graphql/queries/get-executions.ts b/packages/backend/src/graphql/queries/get-executions.ts index 65d85b86..53b6ca3d 100644 --- a/packages/backend/src/graphql/queries/get-executions.ts +++ b/packages/backend/src/graphql/queries/get-executions.ts @@ -1,4 +1,5 @@ import { raw } from 'objection'; +import { DateTime } from 'luxon'; import Context from '../../types/express/context'; import Execution from '../../models/execution'; import paginate from '../../helpers/pagination'; @@ -66,11 +67,21 @@ const getExecutions = async ( if (filters?.updatedAt) { const updatedAtFilter = filters.updatedAt; if (updatedAtFilter.from) { - computedExecutions.where('executions.updated_at', '>=', updatedAtFilter.from); + const isoFromDateTime = DateTime + .fromMillis( + parseInt(updatedAtFilter.from, 10) + ) + .toISO(); + computedExecutions.where('executions.updated_at', '>=', isoFromDateTime); } if (updatedAtFilter.to) { - computedExecutions.where('executions.updated_at', '<=', updatedAtFilter.to); + const isoToDateTime = DateTime + .fromMillis( + parseInt(updatedAtFilter.to, 10) + ) + .toISO(); + computedExecutions.where('executions.updated_at', '<=', isoToDateTime); } }