diff --git a/src/controllers/KpiCapacityController.ts b/src/controllers/KpiCapacityController.ts index da06586..60e054d 100644 --- a/src/controllers/KpiCapacityController.ts +++ b/src/controllers/KpiCapacityController.ts @@ -22,7 +22,7 @@ import HttpStatusCode from "../interfaces/http-status"; import { KpiCapacity } from "../entities/kpiCapacity"; import { Position } from "../entities/position"; import { KpiCapacityDetail } from "../entities/kpiCapacityDetail"; -import { Like, In } from "typeorm"; +import { Like, In, Not, IsNull } from "typeorm"; import permission from "../interfaces/permission"; import { RequestWithUser } from "../middlewares/user"; import { setLogDataDiff } from "../interfaces/utils"; @@ -230,13 +230,19 @@ export class kpiCapacityController extends Controller { @Get("group") async GetKpiCapacityTypeGROUP(@Query("positionName") positionName: string) { let position = await this.positionRepository.findOne({ - where: { name: Like(`${positionName}`) }, + where: { + name: Like(`${positionName}`), + kpiLink: Not(IsNull()) || Not("") + }, relations: ["kpiLink", "kpiLink.kpiCapacitys"], }); if (position == null) { position = await this.positionRepository.findOne({ - where: { name: "นักจัดการงานทั่วไป" }, + where: { + name: "นักจัดการงานทั่วไป", + kpiLink: Not(IsNull()) || Not("") + }, relations: ["kpiLink", "kpiLink.kpiCapacitys"], }); }