From 7a605fd11d782b6f2d2960f6fb18819a74d36ed1 Mon Sep 17 00:00:00 2001 From: Tomer Shvadron Date: Mon, 14 Oct 2024 14:09:04 +0300 Subject: [PATCH] feat: small fix for the Ongoing OR condition (#2777) --- .../business-report.controller.internal.ts | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/services/workflows-service/src/business-report/business-report.controller.internal.ts b/services/workflows-service/src/business-report/business-report.controller.internal.ts index cbf90e5cf..449412590 100644 --- a/services/workflows-service/src/business-report/business-report.controller.internal.ts +++ b/services/workflows-service/src/business-report/business-report.controller.internal.ts @@ -235,23 +235,23 @@ export class BusinessReportControllerInternal { @CurrentProject() currentProjectId: TProjectId, @Query() { businessId, batchId, page, search, type, orderBy }: ListBusinessReportsDto, ) { + const ongoingOrCondition = [ + { + type: { + not: { + equals: BusinessReportType.ONGOING_MERCHANT_REPORT_T1, + }, + }, + }, + { + type: BusinessReportType.ONGOING_MERCHANT_REPORT_T1, + status: BusinessReportStatus.completed, + }, + ]; const args = { where: { businessId, batchId, - OR: [ - { - type: { - not: { - equals: BusinessReportType.ONGOING_MERCHANT_REPORT_T1, - }, - }, - }, - { - type: BusinessReportType.ONGOING_MERCHANT_REPORT_T1, - status: BusinessReportStatus.completed, - }, - ], ...(type ? { type } : {}), ...(search ? { @@ -263,9 +263,10 @@ export class BusinessReportControllerInternal { }, }, { business: { website: { contains: search, mode: QueryMode.Insensitive } } }, + ...ongoingOrCondition, ], } - : {}), + : { OR: ongoingOrCondition }), }, select: { id: true,