feat: Add tracking for node errors and update node graph (#11060)

This commit is contained in:
Mutasem Aldmour
2024-10-15 12:38:17 +02:00
committed by GitHub
parent ecbe568d69
commit d3b05f1c54
10 changed files with 676 additions and 5 deletions

View File

@@ -24,6 +24,8 @@ import type {
IWorkflowBase,
INodeTypes,
IDataObject,
IRunData,
ITaskData,
} from './Interfaces';
import { getNodeParameters } from './NodeHelpers';
@@ -131,6 +133,21 @@ export function getDomainPath(raw: string, urlParts = URL_PARTS_REGEX): string {
}
}
function getNumberOfItemsInRuns(runs: ITaskData[]): number {
return runs.reduce((total, run) => {
const data = run.data ?? {};
let count = 0;
Object.keys(data).forEach((type) => {
const conn = data[type] ?? [];
conn.forEach((branch) => {
count += (branch ?? []).length;
});
});
return total + count;
}, 0);
}
export function generateNodesGraph(
workflow: Partial<IWorkflowBase>,
nodeTypes: INodeTypes,
@@ -138,8 +155,10 @@ export function generateNodesGraph(
sourceInstanceId?: string;
nodeIdMap?: { [curr: string]: string };
isCloudDeployment?: boolean;
runData?: IRunData;
},
): INodesGraphResult {
const { runData } = options ?? {};
const nodeGraph: INodesGraph = {
node_types: [],
node_connections: [],
@@ -200,6 +219,13 @@ export function generateNodesGraph(
position: node.position,
};
if (runData?.[node.name]) {
const runs = runData[node.name] ?? [];
nodeItem.runs = runs.length;
nodeItem.items_total = getNumberOfItemsInRuns(runs);
}
if (options?.sourceInstanceId) {
nodeItem.src_instance_id = options.sourceInstanceId;
}