From 3e7b60839e24a26e7250a4f6f3f14d43a6c64dfa Mon Sep 17 00:00:00 2001 From: joseph le Date: Wed, 4 Oct 2023 09:37:35 +0700 Subject: [PATCH] change runtimeCheckLog --- app/utils/runtimeCheckLogs.ts | 65 ++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/app/utils/runtimeCheckLogs.ts b/app/utils/runtimeCheckLogs.ts index 61d82f8..ea5ebb1 100644 --- a/app/utils/runtimeCheckLogs.ts +++ b/app/utils/runtimeCheckLogs.ts @@ -103,7 +103,8 @@ export async function runtimeCheckLogs(folderPath) { const filePath = path let lines = []; const today = DateTime.now().toFormat('yyyy-MM-dd'); - let allFile = await LogDetectFile.all(); + let allFile = await LogDetectFile.query() + .whereRaw(`DATE(created_at) = ?`, [today]) // let allReport = await LogReport.all(); let allValue = await KeyValue.all(); const allReport = await LogReport.query() @@ -153,40 +154,40 @@ export async function runtimeCheckLogs(folderPath) { .map((obj) => obj.$original.value); //Process file content - // contentFile.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]; + contentFile.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 - // ); + 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 (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()) + }); + }); //true: import log to log_report table, send report to Zulip // setTimeout(async () => {