diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 5278d02..d51bc0d 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -2820,12 +2820,8 @@ export class SalaryPeriodController extends Controller { console.log("mlength", orgProfileEmployees.length); const profilesEmpToSave: SalaryProfileEmployee[] = []; console.time("⏱ SalaryProfileEmployee - Total Time"); - // await Promise.all( - // orgProfileEmployees.map(async (profile: any) => { - - const batchSize = 1000; - for (let i = 0; i < orgProfileEmployees.length; i += batchSize) { - const profile = orgProfileEmployees.slice(i, i + batchSize); + console.time("⏱ Step5: Process ProfileEmps"); + for (const profile of orgProfileEmployees) { const salaryOrgNew = await this.salaryOrgEmployeeRepository.findOne({ where: { salaryPeriodId: salaryPeriod.id, @@ -2884,12 +2880,19 @@ export class SalaryPeriodController extends Controller { salaryProfileNew.isRetired = salaryOld == null ? false : salaryOld.isRetired; salaryProfileNew.isGood = salaryOld == null ? false : salaryOld.isGood; } - // profilesEmpToSave.push(salaryProfileNew); + profilesEmpToSave.push(salaryProfileNew); + await this.salaryProfileEmployeeRepository + .createQueryBuilder() + .insert() + .into(SalaryProfileEmployee) + .values(profilesEmpToSave) + .orIgnore() + .execute(); //console.log(`step10`); // console.log( // `✅ [SNAP: ${snapshot}] Push SalaryProfileEmployee: ${salaryProfileNew.citizenId} (${salaryProfileNew.fullName ?? "-"})`, // ); - await this.salaryProfileEmployeeRepository.save(salaryProfileNew, { data: request }); + // await this.salaryProfileEmployeeRepository.save(salaryProfileNew, { data: request }); // await this.salaryProfileEmployeeRepository.save(profilesEmpToSave, { chunk: 100, data: request }); // setLogDataDiff(request, { before: beforeSalaryProfileNew, after: salaryProfileNew }); } else { @@ -2898,7 +2901,6 @@ export class SalaryPeriodController extends Controller { ); } } - // ); console.timeEnd("⏱ SalaryProfileEmployee - Total Time"); }