From d524e237a455a35457180136ce99cd75b0d12695 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 2 Feb 2021 17:32:27 +0100 Subject: [PATCH] Dataset.js fully debugged --- .../TS/Process-Modules/DataDependencies.js | 69 ++++++++++--------- .../Superalgos/TS/Process-Modules/Dataset.js | 18 +++-- .../UI/Function-Libraries/TaskFunctions.js | 2 + 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js index cc77da285..e45eb7127 100644 --- a/Projects/Superalgos/TS/Process-Modules/DataDependencies.js +++ b/Projects/Superalgos/TS/Process-Modules/DataDependencies.js @@ -108,9 +108,6 @@ TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName - thisObject.filters.exchange.list.set(thisObject.defaultExchange, true) - thisObject.filters.exchange.markets.set(thisObject.defaultExchange + '-' + thisObject.defautMarket, true) - thisObject.filters.market.list.set(true) /* For each dependency declared at the curatedDependencyNodeArray, we will initialize a DataSet as part of this initialization process. */ @@ -184,47 +181,51 @@ */ let product = dataDependency.referenceParent.parentNode.config.singularVariableName - if (thisObject.filters.products.get(exchange + '-' + market + '-' + product) !== true) { + if (thisObject.filters.exchange.products.get(exchange + '-' + market + '-' + product) !== true) { continue } - addDataSets(exchange, market) + addDataSet(exchange, market) + } else { + addDataSet(exchange, market) } - let dataSetModule = TS.projects.superalgos.processModules.dataset.newSuperalgosProcessModulesDataset(processIndex) - dataSetModule.initialize(exchange, market, dataDependency, onInitilized) + function addDataSet(exchange, market) { + let dataSetModule = TS.projects.superalgos.processModules.dataset.newSuperalgosProcessModulesDataset(processIndex) + dataSetModule.initialize(exchange, market, dataDependency, onInitilized) - function onInitilized(err, wasInitialized) { + function onInitilized(err, wasInitialized) { - if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> err = " + JSON.stringify(err)) + if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> err = " + JSON.stringify(err)) - alreadyCalledBack = true - callBackFunction(err) - return - } - - if (wasInitialized === true) { - addCount++ - newNodeArray.push(thisObject.curatedDependencyNodeArray[i]) - addDataSet() - } else { - skipCount++ - } - checkIfWeAreDone() - } - - function addDataSet() { - thisObject.dataSetsModulesArray.push(dataSetModule) - } - - function checkIfWeAreDone() { - if (addCount + skipCount === thisObject.curatedDependencyNodeArray.length) { - if (alreadyCalledBack === false) { alreadyCalledBack = true - thisObject.curatedDependencyNodeArray = newNodeArray - callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) + callBackFunction(err) return } + + if (wasInitialized === true) { + addCount++ + newNodeArray.push(thisObject.curatedDependencyNodeArray[i]) + addDataSet() + } else { + skipCount++ + } + checkIfWeAreDone() + } + + function addDataSet() { + thisObject.dataSetsModulesArray.push(dataSetModule) + } + + function checkIfWeAreDone() { + if (addCount + skipCount === thisObject.curatedDependencyNodeArray.length) { + if (alreadyCalledBack === false) { + alreadyCalledBack = true + thisObject.curatedDependencyNodeArray = newNodeArray + callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) + return + } + } } } } diff --git a/Projects/Superalgos/TS/Process-Modules/Dataset.js b/Projects/Superalgos/TS/Process-Modules/Dataset.js index 3c8ca1199..45a40ffb2 100644 --- a/Projects/Superalgos/TS/Process-Modules/Dataset.js +++ b/Projects/Superalgos/TS/Process-Modules/Dataset.js @@ -280,7 +280,7 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { if (startingNode.referenceParent.parentNode.parentNode === undefined) { return } - if (startingNode.referenceParent.parentNode.parentNode.codeName !== exchange) { + if (startingNode.referenceParent.parentNode.parentNode.config.codeName !== exchange) { return } } @@ -292,14 +292,18 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { switch (property.type) { case 'node': { - scanNodeMesh(startingNode[property.name]) + if (found !== true) { + scanNodeMesh(startingNode[property.name]) + } } break case 'array': { let startingNodePropertyArray = startingNode[property.name] if (startingNodePropertyArray !== undefined) { for (let m = 0; m < startingNodePropertyArray.length; m++) { - scanNodeMesh(startingNodePropertyArray[m]) + if (found !== true) { + scanNodeMesh(startingNodePropertyArray[m]) + } } } break @@ -309,11 +313,15 @@ exports.newSuperalgosProcessModulesDataset = function (processIndex) { } /* We scan parents nodes. */ if (startingNode.parentNode !== undefined) { - scanNodeMesh(startingNode.parentNode) + if (found !== true) { + scanNodeMesh(startingNode.parentNode) + } } /* We scan reference parents too. */ if (startingNode.referenceParent !== undefined) { - scanNodeMesh(startingNode.referenceParent) + if (found !== true) { + scanNodeMesh(startingNode.referenceParent) + } } } } diff --git a/Projects/Superalgos/UI/Function-Libraries/TaskFunctions.js b/Projects/Superalgos/UI/Function-Libraries/TaskFunctions.js index 59da53e38..5a47da8de 100644 --- a/Projects/Superalgos/UI/Function-Libraries/TaskFunctions.js +++ b/Projects/Superalgos/UI/Function-Libraries/TaskFunctions.js @@ -158,6 +158,8 @@ function newSuperalgosFunctionLibraryTaskFunctions() { 'Project Data Products->Project Trading Products->Project Learning Products->' + 'Exchange Data Products->Exchange Trading Products->Exchange Learning Products->' + 'Market Data Products->Market Trading Products->Market Learning Products->' + + 'Market->Market Base Asset->Market Quoted Asset->Asset->' + + 'Exchange Markets->Crypto Exchange->' + 'Data Mine Products->Bot Products->' + 'Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->' + 'Data Product->Product Definition->' +