From 8f83ab781b3c3d765587b11d923587a887cbe424 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Fri, 24 Apr 2026 10:28:30 +0700 Subject: [PATCH] fix.save batch insert --- src/controllers/ProfileSalaryController.ts | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index 8cc9d376..03814161 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -102,10 +102,9 @@ export class ProfileSalaryController extends Controller { Months: month, Days: day, }; - // data.push(_mapData); - await this.positionOfficerRepo.save(mapData); + data.push(mapData); } - // await this.positionOfficerRepo.save(data); + await this.positionOfficerRepo.save(data); return new HttpSuccess(); } @@ -151,10 +150,9 @@ export class ProfileSalaryController extends Controller { Months: month, Days: day, }; - // data.push(_mapData); - await this.positionEmployeeRepo.save(mapData); + data.push(mapData); } - // await this.positionEmployeeRepo.save(data); + await this.positionEmployeeRepo.save(data); return new HttpSuccess(); } @@ -210,10 +208,9 @@ export class ProfileSalaryController extends Controller { Months: x.posLevel == null ? 0 : month.toFixed(4), Days: x.posLevel == null ? 0 : day.toFixed(4), }; - // data.push(_mapData); - await this.levelOfficerRepo.save(mapData); + data.push(mapData); } - // await this.levelOfficerRepo.save(data); + await this.levelOfficerRepo.save(data); return new HttpSuccess(); } @@ -269,16 +266,16 @@ export class ProfileSalaryController extends Controller { Months: x.posLevel == null ? 0 : month.toFixed(4), Days: x.posLevel == null ? 0 : day.toFixed(4), }; - // data.push(_mapData); - await this.levelEmployeeRepo.save(mapData); + data.push(mapData); } - // await this.levelEmployeeRepo.save(data); + await this.levelEmployeeRepo.save(data); return new HttpSuccess(); } @Get("TenurePositionExecutiveOfficer") public async cronjobTenureExecutivePositionOfficer() { + let data: any = []; await this.positionExecutiveOfficerRepo.clear(); const profile = await this.profileRepo.find(); const orgRevision = await this.orgRevisionRepository.findOne({ @@ -339,8 +336,9 @@ export class ProfileSalaryController extends Controller { Months: month.toFixed(4), Days: day.toFixed(4), }; - await this.positionExecutiveOfficerRepo.save(mapData); + data.push(mapData); } + await this.positionExecutiveOfficerRepo.save(data); return new HttpSuccess(); }