From 5cb9bd23722c931709cb0654eb5c885ccbcd32e4 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 29 May 2024 17:49:54 +0700 Subject: [PATCH] fix bug --- src/controllers/KpiLinkController.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/controllers/KpiLinkController.ts b/src/controllers/KpiLinkController.ts index 563d92f..7fb2e0a 100644 --- a/src/controllers/KpiLinkController.ts +++ b/src/controllers/KpiLinkController.ts @@ -240,6 +240,13 @@ export class kpiLinkController extends Controller { ) .getManyAndCount(); + if (_total === 0) { + return new HttpSuccess({ + data: [], + total: 0, + }); + } + const [kpiLink, total] = await AppDataSource.getRepository(KpiLink) .createQueryBuilder("kpiLink") .leftJoinAndSelect("kpiLink.kpiGroup", "kpiGroup") @@ -253,6 +260,13 @@ export class kpiLinkController extends Controller { .orderBy("kpiLink.createdAt", "ASC") .getManyAndCount(); + if (_total === 0) { + return new HttpSuccess({ + data: [], + total: 0, + }); + } + const formattedResponse = kpiLink.map((item) => ({ id: item.id, groupName: item.kpiGroup.nameGroupKPI,