change runtimeCheckLog
This commit is contained in:
		
							parent
							
								
									b238af9d2f
								
							
						
					
					
						commit
						b72cce28dd
					
				| 
						 | 
					@ -156,40 +156,80 @@ export async function runtimeCheckLogs(folderPath) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            console.log(contentFile.length)
 | 
					            console.log(contentFile.length)
 | 
				
			||||||
          //Process file content
 | 
					          //Process file content
 | 
				
			||||||
          contentFile.map((line, index) => {
 | 
					          if(contentFile.length>30000){
 | 
				
			||||||
            //check line the line with errors and exclude errors
 | 
					            for (let i = 0; i < contentFile.length; i += 30000) {
 | 
				
			||||||
            listKeyValues
 | 
					              const chunk = contentFile.slice(i, i + 30000);
 | 
				
			||||||
              .map((obj) => obj.$original.value)
 | 
					              chunk.map((line, index) => {
 | 
				
			||||||
              .map(async (value) => {
 | 
					                //check line the line with errors and exclude errors
 | 
				
			||||||
                if (
 | 
					                listKeyValues
 | 
				
			||||||
                  line.search(value) !== -1 &&
 | 
					                  .map((obj) => obj.$original.value)
 | 
				
			||||||
                  listExcludeErr.filter((err) => line.includes(err))
 | 
					                  .map(async (value) => {
 | 
				
			||||||
                    .length === 0
 | 
					                    if (
 | 
				
			||||||
                ) {
 | 
					                      line.search(value) !== -1 &&
 | 
				
			||||||
                  let log = allFile?.filter(
 | 
					                      listExcludeErr.filter((err) => line.includes(err))
 | 
				
			||||||
                    (i) => i.$original.file_name === fileName
 | 
					                        .length === 0
 | 
				
			||||||
                  )[0];
 | 
					                    ) {
 | 
				
			||||||
 | 
					                      let log = allFile?.filter(
 | 
				
			||||||
 | 
					                        (i) => i.$original.file_name === fileName
 | 
				
			||||||
 | 
					                      )[0];
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
                  let checkLog = allReport?.filter(
 | 
					                      let checkLog = allReport?.filter(
 | 
				
			||||||
                    (report) =>
 | 
					                        (report) =>
 | 
				
			||||||
                      report.$original.id_file === log?.id_ldf &&
 | 
					                          report.$original.id_file === log?.id_ldf &&
 | 
				
			||||||
                      report.$original.line === index + 1 &&
 | 
					                          report.$original.line === index + 1 &&
 | 
				
			||||||
                      report.$original.detected_content === value
 | 
					                          report.$original.detected_content === value
 | 
				
			||||||
                  );
 | 
					                      );
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
                  if (checkLog?.length === 0) {
 | 
					                      if (checkLog?.length === 0) {
 | 
				
			||||||
                    // await LogReport.create({
 | 
					                        // await LogReport.create({
 | 
				
			||||||
                    //   detected_content: value,
 | 
					                        //   detected_content: value,
 | 
				
			||||||
                    //   line: index + 1,
 | 
					                        //   line: index + 1,
 | 
				
			||||||
                    //   id_file: log?.id_ldf,
 | 
					                        //   id_file: log?.id_ldf,
 | 
				
			||||||
                    // });
 | 
					                        // });
 | 
				
			||||||
                    lines.push(index + 1);
 | 
					                        lines.push(index + 1);
 | 
				
			||||||
                  }
 | 
					                      }
 | 
				
			||||||
                }
 | 
					                    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
                // if(checkSpecialVersion())
 | 
					                    // if(checkSpecialVersion())
 | 
				
			||||||
 | 
					                  });
 | 
				
			||||||
              });
 | 
					              });
 | 
				
			||||||
          });
 | 
					            }
 | 
				
			||||||
 | 
					          }else{
 | 
				
			||||||
 | 
					            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
 | 
				
			||||||
 | 
					                    );
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					                    if (checkLog?.length === 0) {
 | 
				
			||||||
 | 
					                      // await LogReport.create({
 | 
				
			||||||
 | 
					                      //   detected_content: value,
 | 
				
			||||||
 | 
					                      //   line: index + 1,
 | 
				
			||||||
 | 
					                      //   id_file: log?.id_ldf,
 | 
				
			||||||
 | 
					                      // });
 | 
				
			||||||
 | 
					                      lines.push(index + 1);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                  }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					                  // if(checkSpecialVersion())
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          //true: import log to log_report table, send report to Zulip
 | 
					          //true: import log to log_report table, send report to Zulip
 | 
				
			||||||
          // setTimeout(async () => {
 | 
					          // setTimeout(async () => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
let a = [1,2,3]
 | 
					let a = [1,2,3]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
console.log(a.map(i=>i+1))
 | 
					console.log(a.slice(0,4))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue