From dac9c1777eeb6c50f900ed5fb2f587e94531b3f3 Mon Sep 17 00:00:00 2001 From: Narek Hovhannisyan Date: Fri, 10 Jan 2025 16:49:08 +0400 Subject: [PATCH] refactor(lib): use isRegrouped validation logic in computeNode function --- src/if-run/lib/compute.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/if-run/lib/compute.ts b/src/if-run/lib/compute.ts index f77b1b99..6a89ad50 100644 --- a/src/if-run/lib/compute.ts +++ b/src/if-run/lib/compute.ts @@ -1,6 +1,6 @@ import {PluginParams} from '@grnsft/if-core/types'; -import {Regroup} from './regroup'; +import {isRegrouped, Regroup} from './regroup'; import {addExplainData} from './explain'; import {debugLogger} from '../../common/util/debug-logger'; @@ -23,7 +23,7 @@ const { SKIPPING_REGROUP, } = STRINGS; -const childNames = new Set(); +const childNames = new Set(); /** * Traverses all child nodes based on children grouping. @@ -147,16 +147,7 @@ const computeNode = async (node: Node, params: ComputeParams): Promise => { if ((noFlags || params.regroup) && pipelineCopy.regroup) { const originalOutputs = params.append ? node.outputs || [] : []; - // Grabs all the values according to grouping criteria. - const regroupValues = pipelineCopy.regroup - .map(group => [...new Set(outputStorage.map(output => output[group]))]) - .flat(); - // Checks if regroup values are present in the children list. - const isRegrouped = regroupValues.every(one => - [...childNames].includes(one) - ); - - if (!isRegrouped) { + if (!isRegrouped(pipelineCopy.regroup, outputStorage, childNames)) { node.children = Regroup( outputStorage, originalOutputs,