From d35c16ac03fea7aca770e2bca5192396e6162d36 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 16 Feb 2024 13:03:42 -0300 Subject: [PATCH] Refactor buildVertices function to optimize component execution --- src/frontend/src/utils/buildUtils.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/utils/buildUtils.ts b/src/frontend/src/utils/buildUtils.ts index 16d036423..bf4b12ee4 100644 --- a/src/frontend/src/utils/buildUtils.ts +++ b/src/frontend/src/utils/buildUtils.ts @@ -26,10 +26,11 @@ export async function buildVertices({ for (let i = 0; i < verticesOrder.length; i += 1) { const innerArray = verticesOrder[i]; const idIndex = innerArray.indexOf(nodeId); - if (idIndex !== -1) { - // If the targetId is found in the inner array, cut the array before the id - vertices.push(innerArray.slice(0, idIndex + 1)); + // If there's a nodeId, we want to run just that component and not the entire layer + // because a layer contains dependencies for the next layer + // and we are stopping at the layer that contains the nodeId + vertices.push([innerArray[idIndex]]); break; // Stop searching after finding the first occurrence } // If the targetId is not found, include the entire inner array @@ -38,7 +39,7 @@ export async function buildVertices({ } else { vertices = verticesOrder; } - + console.log("Vertices: ", vertices); const buildResults: Array = []; for (let i = 0; i < vertices.length; i += 1) { await Promise.all(