update index.js and process.js

main
MohammadHoseinPaymard 1 month ago
parent c14342a2d1
commit b013919fd2
  1. 73
      index.js
  2. 6
      process.js

@ -3,48 +3,51 @@ const { sleep } = require('./util');
const { getAllWorkflows } = require('./workflow');
const { getAllProcesses, getProcessPaths } = require('./process');
require(path.join(process.cwd(),"..","server","dist","database.js"));
require(path.join(process.cwd(), "..", "server", "dist", "database.js"));
(async function(){
(async function () {
await sleep(5e3);
console.time("WorkflowTester")
console.log("initilizing begin..");
const workflows = await getAllWorkflows({
id:{
[Op.gt] : 0
id: {
[Op.gt]: 0
}
});
if(workflows.length==0) throw "There is not any workflow";
if (workflows.length == 0) throw "There is not any workflow";
const allWorkflowInfo = {};
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:{
for await (const workflow of workflows) {
if (+workflow.id < 0) continue;
const processes = await getAllProcesses(workflow, {
subFlowId: null,
});
if (processes.length == 0) {
allWorkFlowInfo[workflow.id] = {
isValid: false,
root: {
valid: 0,
invalid: 0,
subFlowList: []
},
subFlow:{}
subFlow: {}
}
continue workflowsFor;
}
const { allPaths: tree, subFlowParentIds, invalidPathsWithoutEnding } = await getProcessPaths(processes, workflow);
allWorkFlowInfo[workflow.id] = {
isValid: invalidPathsWithoutEnding.length == 0 ? true : false,
root: {
validPaths:tree,
invalidPaths:invalidPathsWithoutEnding,
validPaths: tree,
invalidPaths: invalidPathsWithoutEnding,
valid: tree.length,
invalid: invalidPathsWithoutEnding.length,
subFlowList: subFlowParentIds
@ -52,8 +55,38 @@ require(path.join(process.cwd(),"..","server","dist","database.js"));
subFlow: {}
}
const subFlowInfo = {}
subFlowFor:
for await (const subFlowId of subFlowParentIds) {
const processesSubFlow = await getAllProcesses(workflow, {
[Op.or]: [
{
subFlowId: subFlowId,
},
{
subFlowPid: subFlowId
}
]
})
if (processesSubFlow.length == 0) {
allWorkFlowInfo[workflow.id].isValid = false;
subFlowInfo[subFlowId] = {
valid: subTreePath.length,
invalid: invalidSubPathsWithoutEnding.length,
validSubTreePath:subTreePath,
invalidSubTreePath: invalidSubPathsWithoutEnding
}
continue subFlowFor;
}
}
allWorkFlowInfo[workflow.id]["subFlow"] = subFlowInfo;
console.log("allWorkFlowInfo",JSON.stringify(allWorkFlowInfo,null,2));
}
console.timeEnd("WorkflowTester")
console.log("DONE");
})()

@ -2,7 +2,6 @@ const getAllProcesses = async (workflow,query = {}) => {
const processes = await bpmsDB.bpms_process.findAll({
where: {
workflowId: workflow.id,
subFlowId: null,
...query
// type:{
// [Op.in]:[0,1]
@ -181,7 +180,7 @@ function getProcessPathsSubFlow(data, subFlowIdTemp, workflow) {
if (startNodes?.length === 0 || !startNodes) {
// return [];
invalidSubPathsWithoutEnding.push({ path: null, data: null, workflow: workflow.id, subworkflow: subFlowIdTemp });
invalidSubPathsWithoutEnding.push({ path: null, data: null, workflow: workflow.id, subworkflow: subFlowIdTemp,error:"هیچ پروسس استارتی برای این ورک فلو وجود ندارد" });
return {
subTreePath: [],
invalidSubPathsWithoutEnding
@ -257,7 +256,8 @@ function getProcessPathsSubFlow(data, subFlowIdTemp, workflow) {
if (nextNodes?.length === 0) {
if (isUniquePath(newPath)) {
// allPaths.push({path:newPath.map(n => n.id),data:newMergedData});
invalidSubPathsWithoutEnding.push({ path: newPath.map(n => n.id), data: newMergedData });
invalidSubPathsWithoutEnding.push({ path: newPath.map(n => n.id), data: newMergedData ,error:"هیچ پروسس پایانی برای این ورک فلو وجود ندارد"});
}
return;
}

Loading…
Cancel
Save