fix(editor): Implement dirty nodes for partial executions (#11739)

Co-authored-by: Danny Martini <danny@n8n.io>
This commit is contained in:
Raúl Gómez Morales
2024-11-28 14:04:55 +01:00
committed by GitHub
parent 57d3269e40
commit b8da4ff9ed
14 changed files with 270 additions and 18 deletions

View File

@@ -37,6 +37,25 @@ import { get } from 'lodash-es';
import { useExecutionsStore } from '@/stores/executions.store';
import { useLocalStorage } from '@vueuse/core';
const getDirtyNodeNames = (
runData: IRunData,
getParametersLastUpdate: (nodeName: string) => number | undefined,
): string[] | undefined => {
const dirtyNodeNames = Object.entries(runData).reduce<string[]>((acc, [nodeName, tasks]) => {
if (!tasks.length) return acc;
const updatedAt = getParametersLastUpdate(nodeName) ?? 0;
if (updatedAt > tasks[0].startTime) {
acc.push(nodeName);
}
return acc;
}, []);
return dirtyNodeNames.length ? dirtyNodeNames : undefined;
};
export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof useRouter> }) {
const nodeHelpers = useNodeHelpers();
const workflowHelpers = useWorkflowHelpers({ router: useRunWorkflowOpts.router });
@@ -244,6 +263,13 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
startRunData.destinationNode = options.destinationNode;
}
if (startRunData.runData) {
startRunData.dirtyNodeNames = getDirtyNodeNames(
startRunData.runData,
workflowsStore.getParametersLastUpdate,
);
}
// Init the execution data to represent the start of the execution
// that data which gets reused is already set and data of newly executed
// nodes can be added as it gets pushed in