From 58104d9b01923f3f3d744a7513ae19d09f0dbf09 Mon Sep 17 00:00:00 2001 From: joseph le Date: Wed, 4 Oct 2023 10:22:10 +0700 Subject: [PATCH] change runtimeCheckLog --- app/utils/runtimeCheckLogs.ts | 68 ++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/app/utils/runtimeCheckLogs.ts b/app/utils/runtimeCheckLogs.ts index 6b882cc..7ac435a 100644 --- a/app/utils/runtimeCheckLogs.ts +++ b/app/utils/runtimeCheckLogs.ts @@ -159,40 +159,42 @@ export async function runtimeCheckLogs(folderPath) { if(contentFile.length>30000){ for (let i = 0; i < contentFile.length; i += 10000) { const chunk = contentFile.slice(i, i + 10000); - chunk.map((line, index) => { - //check line the line with errors and exclude errors - listKeyValues - .map((obj) => obj.$original.value) - .map(async (value) => { - if ( - line.search(value) !== -1 && - listExcludeErr.filter((err) => line.includes(err)) - .length === 0 - ) { - let log = allFile?.filter( - (i) => i.$original.file_name === fileName - )[0]; - - let checkLog = allReport?.filter( - (report) => - report.$original.id_file === log?.id_ldf && - report.$original.line === index + 1 && - report.$original.detected_content === value - ); - - if (checkLog?.length === 0) { - // await LogReport.create({ - // detected_content: value, - // line: index + 1, - // id_file: log?.id_ldf, - // }); - lines.push(index + 1); + setTimeout(() => { + chunk.map((line, index) => { + //check line the line with errors and exclude errors + listKeyValues + .map((obj) => obj.$original.value) + .map(async (value) => { + if ( + line.search(value) !== -1 && + listExcludeErr.filter((err) => line.includes(err)) + .length === 0 + ) { + let log = allFile?.filter( + (i) => i.$original.file_name === fileName + )[0]; + + let checkLog = allReport?.filter( + (report) => + report.$original.id_file === log?.id_ldf && + report.$original.line === index + 1 && + report.$original.detected_content === value + ); + + if (checkLog?.length === 0) { + // await LogReport.create({ + // detected_content: value, + // line: index + 1, + // id_file: log?.id_ldf, + // }); + lines.push(index + 1); + } } - } - - // if(checkSpecialVersion()) - }); - }); + + // if(checkSpecialVersion()) + }); + }); + }, 3000); } }else{ contentFile.map((line, index) => {