From 290ccdf7043f98d525e4b1b966a3eb13b0d82b15 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 11 Jul 2024 17:23:10 +0700 Subject: [PATCH] fix --- src/controllers/ReportController.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 1acdc8d..2d2caff 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -300,7 +300,7 @@ export class ReportController extends Controller { const profileEvaluationNowYearIds = await AppDataSource.getRepository(KpiUserEvaluation) .createQueryBuilder("kpiUserEvaluation") .leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod") - .where("kpiUserEvaluation.profileId = :profileId", { profileId: requestBody.profileId }) + // .where("kpiUserEvaluation.profileId = :profileId", { profileId: requestBody.profileId }) // .where("kpiPeriod.year = :year", { year: yearNow }) .groupBy("kpiUserEvaluation.kpiPeriodId") .select("MIN(kpiUserEvaluation.id) as id") @@ -341,8 +341,8 @@ export class ReportController extends Controller { // สร้าง formatData const combinedDatas = Object.values(groupedEvaluations).map((group: any) => { const data: any = { - fullName: group.fullName, - year: group.year, + fullName: group.fullName ?? null, + year: group.year ?? null, }; group.evaluations.forEach((evaluation: any) => { @@ -389,15 +389,15 @@ export class ReportController extends Controller { evaluation.summaryPoint < 60 ? Extension.ToThaiNumber(evaluation.summaryPoint.toString()) : null; - data.periodOCT = evaluation.kpiPeriod.durationKPI; + data.periodOCT = evaluation.kpiPeriod.durationKPI ?? null; } }); return data; }); - formattedData = { - combinedDatas: combinedDatas.length > 0 ? combinedDatas:[{}], - fullName: combinedDatas[0]["fullName"], + formattedData = { + combinedDatas: combinedDatas.length > 0 ? combinedDatas : [{}], + fullName: combinedDatas[0]["fullName"] ?? null, }; } } @@ -462,7 +462,7 @@ export class ReportController extends Controller { const profileEvaluationIds = await AppDataSource.getRepository(KpiUserEvaluation) .createQueryBuilder("kpiUserEvaluation") .leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod") - .where("kpiUserEvaluation.profileId = :profileId", { profileId: requestBody.profileId }) + // .where("kpiUserEvaluation.profileId = :profileId", { profileId: requestBody.profileId }) .andWhere("kpiPeriod.year BETWEEN :startYear AND :endYear", { startYear: yearNow - 4, endYear: yearNow, @@ -673,7 +673,7 @@ export class ReportController extends Controller { const profileEvaluationIds = await AppDataSource.getRepository(KpiUserEvaluation) .createQueryBuilder("kpiUserEvaluation") .leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod") - .where("kpiUserEvaluation.profileId = :profileId", { profileId: requestBody.profileId }) + // .where("kpiUserEvaluation.profileId = :profileId", { profileId: requestBody.profileId }) .andWhere("kpiPeriod.year BETWEEN :startYear AND :endYear", { startYear: yearNow - 2, endYear: yearNow, @@ -826,7 +826,7 @@ export class ReportController extends Controller { const profileEvaluationIds = await AppDataSource.getRepository(KpiUserEvaluation) .createQueryBuilder("kpiUserEvaluation") .leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod") - .where("kpiUserEvaluation.profileId = :profileId", { profileId: requestBody.profileId }) + // .where("kpiUserEvaluation.profileId = :profileId", { profileId: requestBody.profileId }) .andWhere("kpiUserEvaluation.kpiPeriodId = :kpiPeriodId", { kpiPeriodId: requestBody.periodId, }) @@ -868,7 +868,7 @@ export class ReportController extends Controller { }), ); - const fullNameParts = [userInfo[0].child4, userInfo[0].child3, userInfo[0].child2, userInfo[0].child1, userInfo[0].org]; + const fullNameParts = [userInfo[0]?.child4, userInfo[0]?.child3, userInfo[0]?.child2, userInfo[0]?.child1, userInfo[0]?.org]; const affiliation = fullNameParts .filter((part) => part !== undefined && part !== null) .join("/"); @@ -876,8 +876,8 @@ export class ReportController extends Controller { fullName: userInfo ? userInfo[0].prefix + userInfo[0].firstName + " " + userInfo[0].lastName : null, - affiliation: affiliation, - durationKPI: data?.durationKPI, + affiliation: affiliation ?? null, + durationKPI: data?.durationKPI ?? null, position: userInfo ? userInfo[0].position : null, posType: userInfo ? userInfo[0].posTypeName : null, posLevel: userInfo ? userInfo[0].posLevelName : null,