You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

59 lines
1.6 KiB

const path = require('path');
const { sleep } = require('./util');
const { getAllWorkflows } = require('./workflow');
const { getAllProcesses, getProcessPaths } = require('./process');
require(path.join(process.cwd(),"..","server","dist","database.js"));
(async function(){
await sleep(5e3);
console.time("WorkflowTester")
console.log("initilizing begin..");
const workflows = await getAllWorkflows({
id:{
[Op.gt] : 0
}
});
if(workflows.length==0) throw "There is not any workflow";
const allWorkflowInfo = {};
workflowsFor:
for await(const workflow of workflows){
if(+workflow.id < 0) continue;
const processes = await getAllProcesses(workflow);
if(processes.length == 0){
allWorkflowInfo[workflow.id] = {
isValid:false,
root:{
valid: 0,
invalid: 0,
subFlowList: []
},
subFlow:{}
}
continue workflowsFor;
}
const { allPaths: tree, subFlowParentIds, invalidPathsWithoutEnding } = await getProcessPaths(processes, workflow);
allWorkFlowInfo[workflow.id] = {
root: {
validPaths:tree,
invalidPaths:invalidPathsWithoutEnding,
valid: tree.length,
invalid: invalidPathsWithoutEnding.length,
subFlowList: subFlowParentIds
},
subFlow: {}
}
}
console.timeEnd("WorkflowTester")
console.log("DONE");
})()