From 9cd3126c7a28b38ac5498fa8bceb347336c34e8e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 19 Mar 2019 15:00:22 +0100 Subject: [PATCH 1/2] LOG ERROR when file is not in valid JSON format --- src/FileCloud.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/FileCloud.js b/src/FileCloud.js index 49e5002c7..1acddf35c 100644 --- a/src/FileCloud.js +++ b/src/FileCloud.js @@ -185,14 +185,17 @@ function newFileCloud () { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, data) return } catch (err) { - if (INFO_LOG === true) { logger.write('[WARN] getFile -> getFileRecursively -> onFileReceived -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[WARN] getFile -> getFileRecursively -> onFileReceived -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> containerName = ' + containerName) } + if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> filePath = ' + filePath) } + if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> fileName = ' + fileName) } let customErr = { result: GLOBAL.CUSTOM_OK_RESPONSE.result, message: 'Data not in JSON Format.' } - if (INFO_LOG === true) { logger.write('[WARN] getFile -> getFileRecursively -> onFileReceived -> customErr.message = ' + customErr.message) } + if (ERROR_LOG === true) { logger.write('[WARN] getFile -> getFileRecursively -> onFileReceived -> customErr.message = ' + customErr.message) } callBackFunction(customErr, text) return From 03253296bc5ad251c4f8ccc0ca81359721e8509d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 23 Mar 2019 10:17:30 +0100 Subject: [PATCH 2/2] Clone Id not as a parameter --- src/FileCloud.js | 14 +++++--------- src/FileSequence.js | 35 +++++++---------------------------- 2 files changed, 12 insertions(+), 37 deletions(-) diff --git a/src/FileCloud.js b/src/FileCloud.js index 1acddf35c..763eb92ed 100644 --- a/src/FileCloud.js +++ b/src/FileCloud.js @@ -33,19 +33,15 @@ function newFileCloud () { } } - function getFile (pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction, pOperationsId) { + function getFile (pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction) { try { if (INFO_LOG === true) { logger.write('[INFO] getFile -> Entering function.') } const MAX_RETRIES = 3 - if (pOperationsId !== undefined) { - getFileRecursively(0, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction, pOperationsId) - } else { - getFileRecursively(0, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction) - } + getFileRecursively(0, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction) - function getFileRecursively (pRetryCounter, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction, pOperationsId) { + function getFileRecursively (pRetryCounter, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction) { try { if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> Entering function.') } if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pSet.filePath + '-' + pSet.fileName) } @@ -96,8 +92,8 @@ function newFileCloud () { } if (pBot !== undefined) { - if (pOperationsId !== undefined) { - filePath = filePath.replace('@Bot', pBot.codeName + '-' + pOperationsId) + if (pBot.cloneId !== undefined) { + filePath = filePath.replace('@Bot', pBot.codeName + '-' + pBot.cloneId) } else { filePath = filePath.replace('@Bot', pBot.codeName) } diff --git a/src/FileSequence.js b/src/FileSequence.js index 9bf99f601..ff68362ee 100644 --- a/src/FileSequence.js +++ b/src/FileSequence.js @@ -50,7 +50,7 @@ function newFileSequence () { } } - function initialize (pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, callBackFunction, pOperationsId) { + function initialize (pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, callBackFunction) { try { if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') } if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) } @@ -61,12 +61,7 @@ function newFileSequence () { throw 'Exchange not supoorted by this pProduct of the ecosystem! - pDevTeam.codeName = ' + pDevTeam.codeName + ', pBot.codeName = ' + pBot.codeName + ', pProduct.codeName = ' + pProduct.codeName + ', pExchange = ' + pExchange } - - if (pOperationsId !== undefined) { - intervalHandle = setInterval(function () { updateFiles(pOperationsId) }, _1_MINUTE_IN_MILISECONDS) - } else { - intervalHandle = setInterval(updateFiles, _1_MINUTE_IN_MILISECONDS) - } + intervalHandle = setInterval(updateFiles(), _1_MINUTE_IN_MILISECONDS) if (INFO_LOG === true) { logger.write('[INFO] initialize -> intervalHandle = ' + intervalHandle) } @@ -81,11 +76,7 @@ function newFileSequence () { /* First we will get the sequence max number */ - if (pOperationsId !== undefined) { - fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, 'Sequence', undefined, onSequenceFileReceived, pOperationsId) - } else { - fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, 'Sequence', undefined, onSequenceFileReceived) - } + fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, 'Sequence', undefined, onSequenceFileReceived) function onSequenceFileReceived (err, file) { try { @@ -134,11 +125,7 @@ function newFileSequence () { /* Now we will get the sequence of files */ for (let i = 0; i <= maxSequence; i++) { - if (pOperationsId !== undefined) { - fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, i, undefined, onFileReceived, pOperationsId) - } else { - fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, i, undefined, onFileReceived) - } + fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, i, undefined, onFileReceived) function onFileReceived (err, file) { try { @@ -191,7 +178,7 @@ function newFileSequence () { } } - function updateFiles (pOperationsId) { + function updateFiles () { try { let updateFiles = 0 @@ -216,11 +203,7 @@ function newFileSequence () { if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> bot = ' + bot.codeName) } if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> thisSet = ' + thisSet.codeName) } - if (pOperationsId !== undefined) { - fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, 'Sequence', undefined, onSequenceFileReceived, pOperationsId) - } else { - fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, 'Sequence', undefined, onSequenceFileReceived) - } + fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, 'Sequence', undefined, onSequenceFileReceived) function onSequenceFileReceived (err, file) { try { @@ -265,11 +248,7 @@ function newFileSequence () { for (let i = currentMaxSequence; i <= maxSequence; i++) { if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> i = ' + i) } - if (pOperationsId !== undefined) { - fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, i, undefined, onFileReceived, pOperationsId) - } else { - fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, i, undefined, onFileReceived) - } + fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, i, undefined, onFileReceived) function onFileReceived (err, file) { try {