From 7245a0a5990cb05ef9847a4afba09a7deb19c537 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Thu, 26 Oct 2023 15:29:28 +0000 Subject: [PATCH] refactor(queries/get-executions): use createdAt in filters --- .../src/graphql/queries/get-executions.ts | 20 +++++++++---------- packages/backend/src/graphql/schema.graphql | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/backend/src/graphql/queries/get-executions.ts b/packages/backend/src/graphql/queries/get-executions.ts index 9ea50144..64b2d6b3 100644 --- a/packages/backend/src/graphql/queries/get-executions.ts +++ b/packages/backend/src/graphql/queries/get-executions.ts @@ -7,7 +7,7 @@ import paginate from '../../helpers/pagination'; type Filters = { flowId?: string; status?: string; - updatedAt?: { + createdAt?: { from?: string; to?: string; }; @@ -46,7 +46,7 @@ const getExecutions = async ( .joinRelated('executionSteps as execution_steps') .select('executions.*', raw(selectStatusStatement)) .groupBy('executions.id') - .orderBy('updated_at', 'desc'); + .orderBy('created_at', 'desc'); const computedExecutions = Execution .query() @@ -66,24 +66,24 @@ const getExecutions = async ( computedExecutions.where('executions.status', filters.status); } - if (filters?.updatedAt) { - const updatedAtFilter = filters.updatedAt; - if (updatedAtFilter.from) { + if (filters?.createdAt) { + const createdAtFilter = filters.createdAt; + if (createdAtFilter.from) { const isoFromDateTime = DateTime .fromMillis( - parseInt(updatedAtFilter.from, 10) + parseInt(createdAtFilter.from, 10) ) .toISO(); - computedExecutions.where('executions.updated_at', '>=', isoFromDateTime); + computedExecutions.where('executions.created_at', '>=', isoFromDateTime); } - if (updatedAtFilter.to) { + if (createdAtFilter.to) { const isoToDateTime = DateTime .fromMillis( - parseInt(updatedAtFilter.to, 10) + parseInt(createdAtFilter.to, 10) ) .toISO(); - computedExecutions.where('executions.updated_at', '<=', isoToDateTime); + computedExecutions.where('executions.created_at', '<=', isoToDateTime); } } diff --git a/packages/backend/src/graphql/schema.graphql b/packages/backend/src/graphql/schema.graphql index 2b54264d..f5b50500 100644 --- a/packages/backend/src/graphql/schema.graphql +++ b/packages/backend/src/graphql/schema.graphql @@ -799,14 +799,14 @@ type Notification { description: String } -input ExecutionUpdatedAtFilterInput { +input ExecutionCreatedAtFilterInput { from: String to: String } input ExecutionFiltersInput { flowId: String - updatedAt: ExecutionUpdatedAtFilterInput + createdAt: ExecutionCreatedAtFilterInput status: String }