From b3563d24fedad1ed63de95894b2a38d7b08a2554 Mon Sep 17 00:00:00 2001 From: 9808us <9808us@pm.me> Date: Sat, 16 Jan 2021 15:12:43 +0100 Subject: [PATCH 01/22] This is my contribution to Superalgos --- .../docs-languages-004-docs-in-italian.json | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/Projects/Superalgos/Schemas/Docs-Topics/docs-languages-004-docs-in-italian.json b/Projects/Superalgos/Schemas/Docs-Topics/docs-languages-004-docs-in-italian.json index b6d77bcf3..df1b51e9b 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/docs-languages-004-docs-in-italian.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/docs-languages-004-docs-in-italian.json @@ -3,25 +3,60 @@ "pageNumber": "4", "type": "Docs In Italian", "definition": { - "text": "The Docs articles are fully written in English. The system allow users to search / browse articles in other languages as well, as long as other users contribute translations." + "text": "The Docs articles are fully written in English. The system allow users to search / browse articles in other languages as well, as long as other users contribute translations.", + "translations": [ + { + "language": "IT", + "text": "La guida di Superalgos è scritta interamente in inglese ma anche tu puoi aiutare a tradurre nella tua lingua preferita. Il sistema attualmente consente agli utenti di cercare o sfogliare la guida anche in altre lingue purché altri utenti contribuiscano alle traduzioni.", + "updated": 1610794887971 + } + ] }, "paragraphs": [ { "style": "Text", - "text": "Superalgos and any other integrated project are written in English, since English is considered the default language. Node types, variable names, etc., all is originally in English language. " + "text": "Superalgos and any other integrated project are written in English, since English is considered the default language. Node types, variable names, etc., all is originally in English language. ", + "translations": [ + { + "language": "IT", + "text": "Superalgos e gli altri progetti integrati sono scritti in inglese perchè considerata la lingua predefinita. Tipi di nodi, nomi di variabili, ecc., Tutto è originariamente in lingua inglese.", + "updated": 1610806159263 + } + ] }, { "style": "Text", - "text": "The Docs content can be translated by anyone willing to contribute some time doing so. That helps users to read the contents of the Docs in their native language. " + "text": "The Docs content can be translated by anyone willing to contribute some time doing so. That helps users to read the contents of the Docs in their native language. ", + "translations": [ + { + "language": "IT", + "text": "Il contenuto della guida può essere tradotto da chiunque desideri contribuire! Così facendo aiuterai gli utenti a leggere i contenuti della guida nella loro lingua madre e tu potrai dare il tuo contributo.", + "updated": 1610806232380 + } + ] }, { "style": "Success", "text": " Users can switch between languages using the links provided at the footer of every page at the Docs. ", - "updated": 1609085068937 + "updated": 1609085068937, + "translations": [ + { + "language": "IT", + "text": "Gli utenti possono passare da una lingua all'altra utilizzando i collegamenti che si trovano nel footer di ogni pagina in questa guida.", + "updated": 1610806272356 + } + ] }, { "style": "Note", - "text": "You can only add or delete pages to the Docs if you are navigating it in English, because English is the default language, and from there pages are later translated. " + "text": "You can only add or delete pages to the Docs if you are navigating it in English, because English is the default language, and from there pages are later translated. ", + "translations": [ + { + "language": "IT", + "text": "Puoi aggiungere o eliminare le pagine della guida solo se stai navigando in inglese perché è la lingua predefinita e da lì le pagine possono essere tradotte in seguito.", + "updated": 1610806324698 + } + ] } ] } \ No newline at end of file From 22b5f95b6b77b44141358b82b5e25fa8cb561c2b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:08:14 +0100 Subject: [PATCH 02/22] test --- .../Schemas/Docs-Concepts/backup-entity - Copy.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json diff --git a/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json b/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json new file mode 100644 index 000000000..fb1139bf6 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json @@ -0,0 +1,13 @@ +{ + "type": "Backup Entity", + "definition": { + "text": "Downloads a JSON file with the entity, which may be to whole Workspace or a node, including references concerning the particular node and its offspring. Use this feature to save your entire workspace or any particular structure of nodes within your workspace so that you may later restore the information, including all references, should you need to. For your reference, the file downloaded is named Backup followed by the name of the entity you are backing up.", + "updated": 1610032969934 + }, + "paragraphs": [ + { + "style": "Text", + "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode." + } + ] +} \ No newline at end of file From c61db756d673da81b8b07c2cbbd132ce72b75ab4 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:09:52 +0100 Subject: [PATCH 03/22] test update conflict --- .../Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json b/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json index fb1139bf6..62e7d7d82 100644 --- a/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json +++ b/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json @@ -1,5 +1,5 @@ { - "type": "Backup Entity", + "type": "Backup Entity CONFLICT CREATED", "definition": { "text": "Downloads a JSON file with the entity, which may be to whole Workspace or a node, including references concerning the particular node and its offspring. Use this feature to save your entire workspace or any particular structure of nodes within your workspace so that you may later restore the information, including all references, should you need to. For your reference, the file downloaded is named Backup followed by the name of the entity you are backing up.", "updated": 1610032969934 From ac891d603d34fdfd27fdee7ce3bdee14d17f0a55 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:17:42 +0100 Subject: [PATCH 04/22] Error Handling Improved for command app.update --- Client/httpInterface.js | 46 +++++++++++++--- .../Docs-Concepts/backup-entity - Copy.json | 13 ----- ...ds-errors-003-app-error-update-failed.json | 52 +++++++++++++++++++ ...rs-001-ts-task-error-unexpected-error.json | 20 +++++-- .../UI/Spaces/Docs-Space/CommandInterface.js | 9 +++- 5 files changed, 116 insertions(+), 24 deletions(-) delete mode 100644 Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 253b4e4a1..3b00911b9 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -666,7 +666,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...') + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...') console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) @@ -699,16 +699,49 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE update() async function update() { - let message = await doGit() + let result = await doGit() - if (message !== undefined) { + if (result.error === undefined) { let customResponse = { result: global.CUSTOM_OK_RESPONSE.result, - message: message + message: result.message } respondWithContent(JSON.stringify(customResponse), httpResponse) } else { - respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'App Error - Update Failed', + anchor: 'Anchor Update Failed', + placeholder: {} + } + + if (result.error.message !== undefined) { + docs.placeholder.errorMessage = { + style: 'Error', + text: result.error.message + } + } + if (result.error.stack !== undefined) { + docs.placeholder.errorStack = { + style: 'Javascript', + text: result.error.stack + } + } + if (result.error.code !== undefined) { + docs.placeholder.errorCode = { + style: 'Json', + text: result.error.code + } + } + + let customResponse = { + result: global.CUSTOM_FAIL_RESPONSE.result, + docs: docs + } + + respondWithContent(JSON.stringify(customResponse), httpResponse) } } @@ -724,10 +757,11 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE let message try { message = await git.pull('https://github.com/Superalgos/Superalgos', currentBranch) - return message + return { message: message } } catch (err) { console.log('[ERROR] Error updating ' + currentBranch) console.log(err.stack) + return { error: err } } } diff --git a/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json b/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json deleted file mode 100644 index 62e7d7d82..000000000 --- a/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "Backup Entity CONFLICT CREATED", - "definition": { - "text": "Downloads a JSON file with the entity, which may be to whole Workspace or a node, including references concerning the particular node and its offspring. Use this feature to save your entire workspace or any particular structure of nodes within your workspace so that you may later restore the information, including all references, should you need to. For your reference, the file downloaded is named Backup followed by the name of the entity you are backing up.", - "updated": 1610032969934 - }, - "paragraphs": [ - { - "style": "Text", - "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode." - } - ] -} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json index 8dec6fa21..d76237dc6 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json @@ -11,6 +11,58 @@ "style": "Success", "text": "Check for the Client's console for details on what may have happened. After you fix the issue, you may try again.", "updated": 1611129360143 + }, + { + "style": "Title", + "text": "Error Details" + }, + { + "style": "Text", + "text": "In the following section you will find the specific information received when this error occured." + }, + { + "style": "Note", + "text": "You will only see it if you opened this page as a result of the error actually happening.", + "updated": 1611151375974 + }, + { + "style": "Subtitle", + "text": "Error Message" + }, + { + "style": "Text", + "text": "The following is the Error Message of the Exception that occured at the Client:", + "updated": 1611151299633 + }, + { + "style": "Placeholder", + "text": "errorMessage" + }, + { + "style": "Subtitle", + "text": "Error Stack" + }, + { + "style": "Text", + "text": "The following is the Error Stack of the Exception that occured at the Client:", + "updated": 1611151427220 + }, + { + "style": "Placeholder", + "text": "errorStack" + }, + { + "style": "Subtitle", + "text": "Error Code" + }, + { + "style": "Text", + "text": "The follwing is the Error Code of the Exception that occured at the Client:", + "updated": 1611151443562 + }, + { + "style": "Placeholder", + "text": "errorCode" } ] } \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/ts-task-errors-001-ts-task-error-unexpected-error.json b/Projects/Superalgos/Schemas/Docs-Topics/ts-task-errors-001-ts-task-error-unexpected-error.json index 69e29808e..31430900c 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/ts-task-errors-001-ts-task-error-unexpected-error.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/ts-task-errors-001-ts-task-error-unexpected-error.json @@ -16,8 +16,20 @@ }, { "style": "Title", - "text": "Error Message", - "updated": 1610971316249 + "text": "Error Details", + "updated": 1611151211050 + }, + { + "style": "Text", + "text": "In the following section you will find the specific information received when this error occured." + }, + { + "style": "Note", + "text": "You will only see it if you opened this page as a result of the error actually happening." + }, + { + "style": "Subtitle", + "text": "Error Message" }, { "style": "Text", @@ -30,7 +42,7 @@ "updated": 1610971337737 }, { - "style": "Title", + "style": "Subtitle", "text": "Error Stack", "updated": 1610968600444 }, @@ -45,7 +57,7 @@ "updated": 1610968640796 }, { - "style": "Title", + "style": "Subtitle", "text": "Error Code" }, { diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index 638d1ed0e..3d462383b 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -136,7 +136,14 @@ function newSuperalgosDocsCommmandInterface() { UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message - Update Done - Already Up-To-Date') } } else { - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error - Update Failed', 'Anchor Update Failed') + UI.projects.superalgos.spaces.docsSpace.navigateTo( + data.docs.project, + data.docs.category, + data.docs.type, + data.docs.anchor, + undefined, + data.docs.placeholder + ) } } } From eb1ad95d66c5f511b74bfa2b484fdcb842eb8e0b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:37:30 +0100 Subject: [PATCH 05/22] This is my contribution to Superalgos --- Client/httpInterface.js | 94 ++++++++++++------- ...s-001-app-error-contribution-not-sent.json | 57 ++++++++++- ...ds-errors-003-app-error-update-failed.json | 4 +- .../UI/Spaces/Docs-Space/CommandInterface.js | 9 +- 4 files changed, 125 insertions(+), 39 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 3b00911b9..c871fc884 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -599,12 +599,34 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE contribute() async function contribute() { - if (await doGit() === false) { - respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + let error + error = await doGit() + if (error !== undefined) { + + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'App Error - Contribution Not Sent', + anchor: undefined, + placeholder: {} + } + + respondWithDocsObject(docs, result.error) return } - if (await doGithub() === false) { - respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + + error = await doGithub() + if (error !== undefined) { + + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'App Error - Contribution Not Sent', + anchor: undefined, + placeholder: {} + } + + respondWithDocsObject(docs, result.error) return } respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) @@ -623,14 +645,13 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE await git.add('./*') await git.commit(commitMessage) await git.push('origin', currentBranch) - return true } catch (err) { console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> Method call produced an error.') console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> err.stack = ' + err.stack) console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> commitMessage = ' + commitMessage) console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> contributionsBranch = ' + contributionsBranch) - return false + return err } } @@ -657,10 +678,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE head, base, }); - return true } catch (err) { if (err.stack.indexOf('A pull request already exists') >= 0) { - return true + return } else { console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> Method call produced an error.') console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack) @@ -670,7 +690,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) - return false + return err } } } @@ -713,35 +733,12 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE project: 'Superalgos', category: 'Topic', type: 'App Error - Update Failed', - anchor: 'Anchor Update Failed', + anchor: undefined, placeholder: {} } - if (result.error.message !== undefined) { - docs.placeholder.errorMessage = { - style: 'Error', - text: result.error.message - } - } - if (result.error.stack !== undefined) { - docs.placeholder.errorStack = { - style: 'Javascript', - text: result.error.stack - } - } - if (result.error.code !== undefined) { - docs.placeholder.errorCode = { - style: 'Json', - text: result.error.code - } - } + respondWithDocsObject(docs, result.error) - let customResponse = { - result: global.CUSTOM_FAIL_RESPONSE.result, - docs: docs - } - - respondWithContent(JSON.stringify(customResponse), httpResponse) } } @@ -831,6 +828,35 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } break } + + function respondWithDocsObject(docs, error) { + + if (error.message !== undefined) { + docs.placeholder.errorMessage = { + style: 'Error', + text: error.message + } + } + if (error.stack !== undefined) { + docs.placeholder.errorStack = { + style: 'Javascript', + text: error.stack + } + } + if (error.code !== undefined) { + docs.placeholder.errorCode = { + style: 'Json', + text: error.code + } + } + + let customResponse = { + result: global.CUSTOM_FAIL_RESPONSE.result, + docs: docs + } + + respondWithContent(JSON.stringify(customResponse), httpResponse) + } } } break diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json index 7a4401674..c9d083363 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json @@ -9,8 +9,61 @@ "paragraphs": [ { "style": "Text", - "text": "Check for the Client's console for details on what may have happened. After you fix the issue that prevented the App Contribute Command to run, you may try again.", - "updated": 1611129009743 + "text": "Check the following section for details on what may have happened. After you fix the issue that prevented the App Contribute Command to run, you may try again.", + "updated": 1611152997869 + }, + { + "style": "Title", + "text": "Error Details" + }, + { + "style": "Text", + "text": "In the following section you will find the specific information received when this error occured." + }, + { + "style": "Note", + "text": "You will only see it if you opened this page as a result of the error actually happening.", + "updated": 1611153032408 + }, + { + "style": "Subtitle", + "text": "Error Message" + }, + { + "style": "Text", + "text": "The following is the Error Message of the Exception that occured at the Client:" + }, + { + "style": "Placeholder", + "text": "errorMessage" + }, + { + "style": "Subtitle", + "text": "Error Stack" + }, + { + "style": "Text", + "text": "The following is the Error Stack of the Exception that occured at the Client:" + }, + { + "style": "Placeholder", + "text": "errorStack" + }, + { + "style": "Subtitle", + "text": "Error Code" + }, + { + "style": "Text", + "text": "The follwing is the Error Code of the Exception that occured at the Client:" + }, + { + "style": "Placeholder", + "text": "errorCode" + }, + { + "style": "Text", + "text": "" } ] } \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json index d76237dc6..55523747f 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json @@ -9,8 +9,8 @@ "paragraphs": [ { "style": "Success", - "text": "Check for the Client's console for details on what may have happened. After you fix the issue, you may try again.", - "updated": 1611129360143 + "text": "Check for the following section for details on what may have happened. After you fix the issue, you may try again.", + "updated": 1611152967185 }, { "style": "Title", diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index 3d462383b..cf63a0021 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -82,7 +82,14 @@ function newSuperalgosDocsCommmandInterface() { if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message - Contribution Done') } else { - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error - Contribution Not Sent', 'Anchor Contribution Not Sent') + UI.projects.superalgos.spaces.docsSpace.navigateTo( + data.docs.project, + data.docs.category, + data.docs.type, + data.docs.anchor, + undefined, + data.docs.placeholder + ) } } } From 3a3bc2ae1b6d7c213b951141a67a711dc9949d20 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:42:11 +0100 Subject: [PATCH 06/22] This is my contribution to Superalgos --- Client/httpInterface.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index c871fc884..04bd72e57 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -595,12 +595,12 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE const token = unescape(requestParameters[5]) const currentBranch = unescape(requestParameters[6]) const contributionsBranch = unescape(requestParameters[7]) + let error contribute() async function contribute() { - let error - error = await doGit() + await doGit() if (error !== undefined) { let docs = { @@ -614,8 +614,8 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE respondWithDocsObject(docs, result.error) return } - - error = await doGithub() + + await doGithub() if (error !== undefined) { let docs = { @@ -651,7 +651,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> commitMessage = ' + commitMessage) console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> contributionsBranch = ' + contributionsBranch) - return err + error = err } } @@ -690,7 +690,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) - return err + error = err } } } From 7b1d6272706b002c9b97b31685231c64aae28788 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:44:13 +0100 Subject: [PATCH 07/22] This is my contribution to Superalgos --- Client/httpInterface.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 04bd72e57..050927e9f 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -690,7 +690,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) - error = err + console.log('error ' ,error) + console.log('err', err) + // error = err } } } From 086db81331c2a54c9b53111cc6bc08f489f3fb0c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:47:36 +0100 Subject: [PATCH 08/22] This is my contribution to Superalgos --- Client/httpInterface.js | 58 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 050927e9f..6125513cf 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -625,7 +625,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE anchor: undefined, placeholder: {} } - + console.log('respond with docs ') respondWithDocsObject(docs, result.error) return } @@ -690,9 +690,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) - console.log('error ' ,error) + console.log('error ', error) console.log('err', err) - // error = err + error = err } } } @@ -830,35 +830,35 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } break } + } - function respondWithDocsObject(docs, error) { + function respondWithDocsObject(docs, error) { - if (error.message !== undefined) { - docs.placeholder.errorMessage = { - style: 'Error', - text: error.message - } - } - if (error.stack !== undefined) { - docs.placeholder.errorStack = { - style: 'Javascript', - text: error.stack - } - } - if (error.code !== undefined) { - docs.placeholder.errorCode = { - style: 'Json', - text: error.code - } - } - - let customResponse = { - result: global.CUSTOM_FAIL_RESPONSE.result, - docs: docs - } - - respondWithContent(JSON.stringify(customResponse), httpResponse) + if (error.message !== undefined) { + docs.placeholder.errorMessage = { + style: 'Error', + text: error.message } + } + if (error.stack !== undefined) { + docs.placeholder.errorStack = { + style: 'Javascript', + text: error.stack + } + } + if (error.code !== undefined) { + docs.placeholder.errorCode = { + style: 'Json', + text: error.code + } + } + + let customResponse = { + result: global.CUSTOM_FAIL_RESPONSE.result, + docs: docs + } + + respondWithContent(JSON.stringify(customResponse), httpResponse) } } break From f013baaaec898475fe197678bb442cb7784e1613 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:48:59 +0100 Subject: [PATCH 09/22] This is my contribution to Superalgos --- Client/httpInterface.js | 45 +++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 6125513cf..a58f3233f 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -834,31 +834,36 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE function respondWithDocsObject(docs, error) { - if (error.message !== undefined) { - docs.placeholder.errorMessage = { - style: 'Error', - text: error.message + try { + if (error.message !== undefined) { + docs.placeholder.errorMessage = { + style: 'Error', + text: error.message + } } - } - if (error.stack !== undefined) { - docs.placeholder.errorStack = { - style: 'Javascript', - text: error.stack + if (error.stack !== undefined) { + docs.placeholder.errorStack = { + style: 'Javascript', + text: error.stack + } } - } - if (error.code !== undefined) { - docs.placeholder.errorCode = { - style: 'Json', - text: error.code + if (error.code !== undefined) { + docs.placeholder.errorCode = { + style: 'Json', + text: error.code + } } + + let customResponse = { + result: global.CUSTOM_FAIL_RESPONSE.result, + docs: docs + } + + respondWithContent(JSON.stringify(customResponse), httpResponse) + } catch(err) { +console.log(err) } - let customResponse = { - result: global.CUSTOM_FAIL_RESPONSE.result, - docs: docs - } - - respondWithContent(JSON.stringify(customResponse), httpResponse) } } break From aed93f3d21b39fd9eb483df7ec3a8e8f683d4d00 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:51:26 +0100 Subject: [PATCH 10/22] This is my contribution to Superalgos --- Client/httpInterface.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index a58f3233f..12b9fdfdf 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -611,7 +611,12 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE placeholder: {} } - respondWithDocsObject(docs, result.error) + try { + respondWithDocsObject(docs, result.error) + + } catch (err) { + console.log('new errro ', err) + } return } @@ -715,6 +720,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } break } + case 'Update': { try { const currentBranch = unescape(requestParameters[3]) @@ -853,15 +859,15 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE text: error.code } } - + let customResponse = { result: global.CUSTOM_FAIL_RESPONSE.result, docs: docs } - + respondWithContent(JSON.stringify(customResponse), httpResponse) - } catch(err) { -console.log(err) + } catch (err) { + console.log(err) } } From 3ca384e94f39dd6b3345b34ecb21c0b6cbf6cb30 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:52:10 +0100 Subject: [PATCH 11/22] This is my contribution to Superalgos --- Client/httpInterface.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 12b9fdfdf..5758cb620 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -631,7 +631,12 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE placeholder: {} } console.log('respond with docs ') - respondWithDocsObject(docs, result.error) + try { + respondWithDocsObject(docs, result.error) + + } catch (err) { + console.log('new errro ', err) + } return } respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) From 5d932ec16d391e721173021d003cfdea0b520a60 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:53:17 +0100 Subject: [PATCH 12/22] This is my contribution to Superalgos --- Client/httpInterface.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 5758cb620..460e6f907 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -611,12 +611,8 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE placeholder: {} } - try { - respondWithDocsObject(docs, result.error) + respondWithDocsObject(docs, result.error) - } catch (err) { - console.log('new errro ', err) - } return } @@ -632,7 +628,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } console.log('respond with docs ') try { - respondWithDocsObject(docs, result.error) + respondWithDocsObject(docs, error) } catch (err) { console.log('new errro ', err) From d9ab664a571bcaa769cdfbdec1f6c514c4261983 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 16:01:36 +0100 Subject: [PATCH 13/22] This is my contribution to Superalgos --- Client/httpInterface.js | 62 +++++++++---------- ...s-001-app-error-contribution-not-sent.json | 18 +++++- ...ds-errors-003-app-error-update-failed.json | 19 +++++- 3 files changed, 65 insertions(+), 34 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 460e6f907..5dc84c54e 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -627,12 +627,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE placeholder: {} } console.log('respond with docs ') - try { - respondWithDocsObject(docs, error) - } catch (err) { - console.log('new errro ', err) - } + respondWithDocsObject(docs, error) + return } respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) @@ -841,35 +838,36 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE function respondWithDocsObject(docs, error) { - try { - if (error.message !== undefined) { - docs.placeholder.errorMessage = { - style: 'Error', - text: error.message - } + if (error.message !== undefined) { + docs.placeholder.errorMessage = { + style: 'Error', + text: error.message } - if (error.stack !== undefined) { - docs.placeholder.errorStack = { - style: 'Javascript', - text: error.stack - } - } - if (error.code !== undefined) { - docs.placeholder.errorCode = { - style: 'Json', - text: error.code - } - } - - let customResponse = { - result: global.CUSTOM_FAIL_RESPONSE.result, - docs: docs - } - - respondWithContent(JSON.stringify(customResponse), httpResponse) - } catch (err) { - console.log(err) } + if (error.stack !== undefined) { + docs.placeholder.errorStack = { + style: 'Javascript', + text: error.stack + } + } + if (error.code !== undefined) { + docs.placeholder.errorCode = { + style: 'Json', + text: error.code + } + } + + docs.placeholder.errorDetails = { + style: 'Json', + text: JSON.stringify(error) + } + + let customResponse = { + result: global.CUSTOM_FAIL_RESPONSE.result, + docs: docs + } + + respondWithContent(JSON.stringify(customResponse), httpResponse) } } diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json index c9d083363..8494a6e76 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json @@ -14,7 +14,8 @@ }, { "style": "Title", - "text": "Error Details" + "text": "Error Info", + "updated": 1611154606702 }, { "style": "Text", @@ -61,6 +62,21 @@ "style": "Placeholder", "text": "errorCode" }, + { + "style": "Subtitle", + "text": "Error Details", + "updated": 1611154543778 + }, + { + "style": "Text", + "text": "The follwing are all the Error details of the Exception that occured at the Client:", + "updated": 1611154675224 + }, + { + "style": "Placeholder", + "text": "errorDetails", + "updated": 1611154555419 + }, { "style": "Text", "text": "" diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json index 55523747f..797d43d15 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json @@ -14,7 +14,8 @@ }, { "style": "Title", - "text": "Error Details" + "text": "Error Info", + "updated": 1611154641024 }, { "style": "Text", @@ -63,6 +64,22 @@ { "style": "Placeholder", "text": "errorCode" + }, + { + "style": "Subtitle", + "text": "Error Details" + }, + { + "style": "Text", + "text": "The follwing are all the Error details of the Exception that occured at the Client:" + }, + { + "style": "Placeholder", + "text": "errorDetails" + }, + { + "style": "Text", + "text": "" } ] } \ No newline at end of file From d910a83a30c7e361b5d394d416b331cc5f584e80 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 16:03:10 +0100 Subject: [PATCH 14/22] This is my contribution to Superalgos --- Client/httpInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 5dc84c54e..6b6dbebe1 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -867,7 +867,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE docs: docs } - respondWithContent(JSON.stringify(customResponse), httpResponse) + respondWithContent(JSON.stringify(customResponse, undefined, 4), httpResponse) } } From ab595e6e315bad54e83adab0dcaf3bf9342f1c0f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 16:05:29 +0100 Subject: [PATCH 15/22] This is my contribution to Superalgos --- Client/httpInterface.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 6b6dbebe1..f34afddc1 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -859,7 +859,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE docs.placeholder.errorDetails = { style: 'Json', - text: JSON.stringify(error) + text: JSON.stringify(error, undefined, 4) } let customResponse = { @@ -867,7 +867,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE docs: docs } - respondWithContent(JSON.stringify(customResponse, undefined, 4), httpResponse) + respondWithContent(JSON.stringify(customResponse), httpResponse) } } From b6056f0d2efbd3141fefe90800960ddc8ee759c1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 16:08:24 +0100 Subject: [PATCH 16/22] This is my contribution to Superalgos --- Client/httpInterface.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index f34afddc1..abe8f07af 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -693,8 +693,6 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) - console.log('error ', error) - console.log('err', err) error = err } } From 5ae4d0aa5bed68f8a4122a16ebb055f1da84fe6e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 16:38:06 +0100 Subject: [PATCH 17/22] Swithching Branches Error Handling Improved, with Docs and Placeholders --- Client/httpInterface.js | 21 ++++-- ...g-branches-current-branch-not-changed.json | 69 ++++++++++++++++++- .../UI/Spaces/Docs-Space/DocsSpace.js | 13 +++- .../UI/Spaces/Docs-Space/DocumentPage.js | 19 ++--- .../Superalgos/UI/Spaces/Docs-Space/Footer.js | 4 +- 5 files changed, 99 insertions(+), 27 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index abe8f07af..82729ce58 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -612,7 +612,6 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } respondWithDocsObject(docs, result.error) - return } @@ -629,7 +628,6 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('respond with docs ') respondWithDocsObject(docs, error) - return } respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) @@ -786,15 +784,25 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE case 'Checkout': { try { const currentBranch = unescape(requestParameters[3]) + let error + checkout() async function checkout() { - let result = await doGit() + await doGit() - if (result === true) { + if (error === undefined) { respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) } else { - respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'Switching Branches - Current Branch Not Changed', + anchor: undefined, + placeholder: {} + } + + respondWithDocsObject(docs, error) } } @@ -811,9 +819,8 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } catch (err) { console.log('[ERROR] Error changing current branch to ' + currentBranch) console.log(err.stack) - return false + error = err } - return true } } catch (err) { diff --git a/Projects/Superalgos/Schemas/Docs-Topics/branches-management-messages-004-switching-branches-current-branch-not-changed.json b/Projects/Superalgos/Schemas/Docs-Topics/branches-management-messages-004-switching-branches-current-branch-not-changed.json index 981b84428..ffd107fd1 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/branches-management-messages-004-switching-branches-current-branch-not-changed.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/branches-management-messages-004-switching-branches-current-branch-not-changed.json @@ -7,10 +7,75 @@ "updated": 1610543788194 }, "paragraphs": [ + { + "style": "Text", + "text": "More detailed info of what caused this failure to switch can be found below.", + "updated": 1611155878425 + }, + { + "style": "Title", + "text": "Error Info" + }, + { + "style": "Text", + "text": "In the following section you will find the specific information received when this error occured." + }, { "style": "Note", - "text": "More detailed info of what caused this failure to switch can be find at the Client's Console.", - "updated": 1610543823314 + "text": "You will only see it if you opened this page as a result of the error actually happening.", + "updated": 1611155956953 + }, + { + "style": "Subtitle", + "text": "Error Message" + }, + { + "style": "Text", + "text": "The following is the Error Message of the Exception that occured at the Client:" + }, + { + "style": "Placeholder", + "text": "errorMessage" + }, + { + "style": "Subtitle", + "text": "Error Stack" + }, + { + "style": "Text", + "text": "The following is the Error Stack of the Exception that occured at the Client:" + }, + { + "style": "Placeholder", + "text": "errorStack" + }, + { + "style": "Subtitle", + "text": "Error Code" + }, + { + "style": "Text", + "text": "The follwing is the Error Code of the Exception that occured at the Client:" + }, + { + "style": "Placeholder", + "text": "errorCode" + }, + { + "style": "Subtitle", + "text": "Error Details" + }, + { + "style": "Text", + "text": "The follwing are all the Error details of the Exception that occured at the Client:" + }, + { + "style": "Placeholder", + "text": "errorDetails" + }, + { + "style": "Text", + "text": "" } ] } \ No newline at end of file diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index 43dc552c2..5b5a66d26 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -21,7 +21,7 @@ function newSuperalgosDocSpace() { paragraphMap: undefined, // Here we will store a map of paragraphs from the Docs Node, Concept, Topics, Tutorials, Reviews or Books Schema in order to find it when we need to update them. textArea: undefined, changeLanguage: changeLanguage, - changeActiveBranch: changeActiveBranch, + changeCurrentBranch: changeCurrentBranch, changeContributionsBranch: changeContributionsBranch, enterEditMode: enterEditMode, exitEditMode: exitEditMode, @@ -183,7 +183,7 @@ function newSuperalgosDocSpace() { initialize() } - function changeActiveBranch(branch) { + function changeCurrentBranch(branch) { httpRequest(undefined, 'App/Checkout/' + branch, onResponse) UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Changing Current Branch') @@ -195,7 +195,14 @@ function newSuperalgosDocSpace() { window.localStorage.setItem('Current Branch', branch) UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Current Branch Changed') } else { - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Current Branch Not Changed') + UI.projects.superalgos.spaces.docsSpace.navigateTo( + data.docs.project, + data.docs.category, + data.docs.type, + data.docs.anchor, + undefined, + data.docs.placeholder + ) } } } diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js index 08b12d7dd..1e9b119d3 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js @@ -476,13 +476,13 @@ function newSuperalgosDocsDocumentPage() { case "Placeholder": { renderParagraph(paragraph, key) editableParagraphIndex++ - let error = addPlaceholdedParagraph(paragraph.text) - if (error !== undefined) { + let result = addPlaceholdedParagraph(paragraph.text) + if (result !== undefined) { paragraph = { - style: "Error", - text: error + style: "Note", + text: result } - key = 'error-paragraph-' + autoGeneratedParagraphIndex + key = 'note-paragraph-' + autoGeneratedParagraphIndex renderParagraph(paragraph, key) autoGeneratedParagraphIndex++ } @@ -622,14 +622,7 @@ function newSuperalgosDocsDocumentPage() { autoGeneratedParagraphIndex++ return } else { - let paragraph = { - type: "Json", - text: JSON.stringify(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.placeholder, undefined, 4) - } - let key = 'placeholded-paragraph-' + autoGeneratedParagraphIndex - renderParagraph(paragraph, key) - autoGeneratedParagraphIndex++ - return 'Property ' + propertyName + ' not found at the placeholder object.' + return 'Property ' + propertyName + ' not found at the placeholder object. This means that within the info recieved, this information is not available.' } } } diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/Footer.js b/Projects/Superalgos/UI/Spaces/Docs-Space/Footer.js index 435963ea9..f5102f069 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/Footer.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/Footer.js @@ -98,8 +98,8 @@ function newSuperalgosDocsFooter() { HTML = HTML + '

Choose the Current Branch

' HTML = HTML + 'You are currently running on the ' + UI.projects.superalgos.utilities.gitBranches.getBranchLabel(UI.projects.superalgos.spaces.docsSpace.currentBranch) + ' branch. Switch to:' HTML = HTML + '' HTML = HTML + '' From 27734e85f4e545a9b7cabdcaa79edd0af82fa069 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 17:18:38 +0100 Subject: [PATCH 18/22] Bug Fixed: removing Github user requirement for app.update command. --- .../UI/Spaces/Docs-Space/CommandInterface.js | 27 ------------------- README.md | 4 +-- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index cf63a0021..63d712553 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -101,33 +101,6 @@ function newSuperalgosDocsCommmandInterface() { } if (UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf('App.Update') !== 0 && UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf('app.update') !== 0) { return 'Not Update Commands' } - /* Set up the commit message */ - let message = UI.projects.superalgos.spaces.docsSpace.commandInterface.command.trim().substring(UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf(' ') + 1, UI.projects.superalgos.spaces.docsSpace.commandInterface.command.length) - if (message.toLowerCase() === 'app.update') { - message = 'Updating my Superalgos Fork and local Repository' - } - - /* Find the Username and Password */ - let apisNode = UI.projects.superalgos.spaces.designSpace.workspace.getHierarchyHeadsByType('APIs') - if (apisNode === undefined) { - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Hierarchy APIs Not Found') - return - } - if (apisNode.githubAPI === undefined) { - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github API Node Not Found') - return - } - - let config = JSON.parse(apisNode.githubAPI.config) - if (config.username === undefined || config.username === "") { - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Config Property Username Not Found') - return - } - if (config.token === undefined || config.token === "") { - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Config Property Token Not Found') - return - } - httpRequest(undefined, 'App/Update/' + UI.projects.superalgos.spaces.docsSpace.currentBranch, onResponse) UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message - Updating Your Local App') diff --git a/README.md b/README.md index 6423b860a..b29d41ed5 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Before you begin, it is recommended that you set up Chrome/Safari as your defaul # Superalgos Client Installation -**1.** Scroll the page all the way to the top. Find and click the **Fork** button to create your fork/copy of this repository. To fork Superalgos you need a GitHub account. If you don't have one, go ahead and create it. A Fork is required for your contributions to the project and to stay up to date with the latest version of the software (more on this later). +**1.** Scroll the page all the way to the top. Find and click the **Fork** button to create your fork/copy of this repository. To fork Superalgos you need a GitHub account. If you don't have one, go ahead and create it. A Fork is required for your contributions to the project (more on this later). **2.** Once the fork is created, you will land on the page of your fork. Copy the URL from your browser's address bar. @@ -74,7 +74,7 @@ git clone https://github.com/John/Superalgos **1.** You need to make a fork so that you may contribute work. Superalgos is a Community project and you are expected to contribute, like everyone else. You don't need to be a technical person to contribute. Fixing a typo in the docs or translating a paragraph into your native language are valuable contributions too. Superalgos has built-in features that make contributing easy. Help make Superalgos better and Superalgos will better serve you! [Free-riding is not cool](https://en.wikipedia.org/wiki/Free-rider_problem), particularly on free, open-source, Community-driven projects. -**2.** You also need a fork to use the in-app self-update feature. It will help you stay up-to-date with the latest version of the software. Updates are on-demand, so don't worry about undesired updates. The project moves very fast and new features become available regularly, particularly if you choose to run the software in the ```develop``` branch (you may switch branches from within the app). +**2.** The software includes an in-app self-update command / feature. It will help you stay up-to-date with the latest version of the software. Updates are on-demand, so don't worry about undesired updates. The project moves very fast and new features become available regularly, particularly if you choose to run the software in the ```develop``` branch (you may switch branches from within the app). **3.** You are better off running the git clone command as an administrator to avoid permission issues while creating the Superalgos folder and downloading the repository. It may work without admin powers depending on your setup, particularly if you are running the command on a folder where you've got write permissions. From 9522b7b8488c0ad68345afa6b1b6558b4096a70b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 17:40:00 +0100 Subject: [PATCH 19/22] Update Message updated --- ...ges-004-app-message-update-done-new-version-found.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-done-new-version-found.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-done-new-version-found.json index e84c8a488..59b350e55 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-done-new-version-found.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-messages-004-app-message-update-done-new-version-found.json @@ -9,8 +9,12 @@ "paragraphs": [ { "style": "Success", - "text": "You now have the latest version of Superalgos. Just remeber to restart the Client and the UI.", - "updated": 1610454408134 + "text": "You now have the latest version of Superalgos. Just remeber to restart the Client and the UI. If you have Tasks running, you should first stop the tasks, and then restart the Client, so that you can run those task again using the updated codebase.", + "updated": 1611160648343 + }, + { + "style": "Note", + "text": "The update you made, only afffects the Client which you are connected to via http using your browser. If you have more Clients running as part of a Network, you will need to update them too, etither manually using Git or by navigating with your browser to their URL and doing running the App Update Command there." } ] } \ No newline at end of file From 1e1fa783cacfb3adb3acc35853aa70b0ea7a022b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 21 Jan 2021 13:33:07 +0100 Subject: [PATCH 20/22] Bug Fix --- .../Exchange-Raw-Data/HistoricOHLCVs.js | 311 +++++++++++++----- 1 file changed, 231 insertions(+), 80 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js index 78a3e9709..48490c50b 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js +++ b/Projects/Superalgos/TS/Bot-Modules/Sensor-Bot/Exchange-Raw-Data/HistoricOHLCVs.js @@ -20,7 +20,6 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { let fetchType = "by Time" let lastId let firstId - let allOHLCVs = [] let thisReport; let since let initialProcessTimestamp @@ -119,6 +118,11 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { function start(callBackFunction) { try { + /* + Initialize the array where we are going to receive the + data from the exchange. + */ + let rawDataArray = [] if (TS.projects.superalgos.globals.taskVariables.IS_TASK_STOPPING === true) { callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); @@ -252,7 +256,7 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { processingDate = processingDate.getUTCFullYear() + '-' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processingDate.getUTCMonth() + 1, 2) + '-' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processingDate.getUTCDate(), 2); TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] start -> getOHLCVs -> Fetching OHLCVs @ " + processingDate + "-> exchange = " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + " -> symbol = " + symbol + " -> since = " + since + " -> limit = " + limit) - let heartBeatText = "Fetching " + allOHLCVs.length.toFixed(0) + " OHLCVs from " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + " " + symbol + " @ " + processingDate + let heartBeatText = "Fetching " + rawDataArray.length.toFixed(0) + " OHLCVs from " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + " " + symbol + " @ " + processingDate let currentDate = new Date(since) let percentage = TS.projects.superalgos.utilities.dateTimeFunctions.getPercentage(fromDate, currentDate, lastDate) TS.projects.superalgos.functionLibraries.processFunctions.processHeartBeat(processIndex, heartBeatText, percentage) // tell the world we are alive and doing well @@ -332,7 +336,7 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { let OHLCVKey = OHLCV[0] + '-' + OHLCV[1].toFixed(16) + '-' + OHLCV[2].toFixed(16) + '-' + OHLCV[3].toFixed(16) + '-' + OHLCV[4].toFixed(16) + '-' + OHLCV[5].toFixed(16) if (OHLCVKey !== lastOHLCVKey) { - allOHLCVs.push(OHLCV) + rawDataArray.push(OHLCV) } lastOHLCVKey = OHLCVKey } @@ -343,7 +347,7 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { if ( OHLCVs.length < limit - 1 || TS.projects.superalgos.globals.taskVariables.IS_TASK_STOPPING === true || - allOHLCVs.length >= MAX_OHLCVs_PER_EXECUTION + rawDataArray.length >= MAX_OHLCVs_PER_EXECUTION ) { break } @@ -376,18 +380,27 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { } async function saveOHLCVs() { + /* + What we are going to do in this function is to save all the candles + received from the exchage. We need to partition the batch of candles + into 1 day files. At the same time we need to take care of the situation + that some exchanges send inconsitent data. We have detected some cases + where candles do not begin at second 0 of the minute but are a little + bit shifted. We will try to detectthis and fix it as we go. + We have the data received from the exchage at the arrary rawDataArray + */ try { let candlesFileContent = '[' let volumesFileContent = '[' - let previousDay = Math.trunc((initialProcessTimestamp - TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) / TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) - let currentDay = Math.trunc((initialProcessTimestamp - TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) / TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) let needSeparator = false let error let separator let heartBeatCounter = 0 - let headOfTheMarketReached = false + let savingProcedureFinished = false + let endOfTheOHLCVArrayReached = false + let currentDay = Math.trunc((initialProcessTimestamp - TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) / TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS) let lastCandle = { begin: 0, @@ -405,55 +418,104 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { sell: 0 } - let i = 0 + let ohlcvArrayIndex = 0 lastId = undefined if (lastCandleOfTheDay !== undefined) { lastCandle = JSON.parse(JSON.stringify(lastCandleOfTheDay)) } + /* + At a macro level, we will be creating one file per day, so we will + run into a loop that each run will represent one day. + */ controlLoop() function loop() { + /* + Here we will try to match the OHLCVs received with each possible + candle of a single day. + */ let filesToCreate = 0 let filesCreated = 0 - /* Go through all possible 1 min candles of a day. */ - for (let j = 0; j < 60 * 24; j++) { + /* + We will loop aroud all the possible 1 minute candles that be found + on a single day. For each minute of the day, we will try to find + the matching OHLCV. This would be an easy task if the exchanges + would allways return consistent data, but that is not the case. + Sometimes, some candles are missing. We have seen also candles that + do not start at an UTC minute, they are shifted in time some seconds. + In order to address all these inconsistencies the process gets a little + bit complicated. + */ + for (let minuteOfTheDay = 0; minuteOfTheDay < 60 * 24; minuteOfTheDay++) { + /* + We initialize our candle and volume objecs positioning them + at the current minute of the day of the current day. We also + initialize them with the last candle and volume property values. + The reason we do this last thing is because we don't knwo if + we are going to find or not a matching OHLCV. If we do find one + these property values will be overwritten, and if not, they will + hold at least the last know value. + */ let candle = { - begin: currentDay * TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS * j, - end: currentDay * TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS * j + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS - 1, + begin: currentDay * TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS * minuteOfTheDay, + end: currentDay * TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS * minuteOfTheDay + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS - 1, open: lastCandle.close, close: lastCandle.close, min: lastCandle.close, max: lastCandle.close } + let volume = { - begin: currentDay * TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS * j, - end: currentDay * TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS * j + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS - 1, + begin: currentDay * TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS * minuteOfTheDay, + end: currentDay * TS.projects.superalgos.globals.timeConstants.ONE_DAY_IN_MILISECONDS + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS * minuteOfTheDay + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS - 1, buy: lastVolume.buy, sell: lastVolume.sell } - let processingDate = new Date(candle.begin) - processingDate = processingDate.getUTCFullYear() + '-' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processingDate.getUTCMonth() + 1, 2) + '-' + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processingDate.getUTCDate(), 2); + /* + Here we will check that the current candle is not going into the future. + Remember we are looping around all possible minutes of a day, and when + that day is the current actual day, and the current minute is in the future, + it manke no more sense to continue inside this loop since we are not going + to find more OHLCVs matchings. - if (candle.begin > (new Date()).valueOf()) { + At the same time, we are going to check that we haven't processed the whole + OHLCV array. Once we reached the end of it, it makes no sense to continue + inside this loop. + */ + if ( + candle.begin > (new Date()).valueOf() || + endOfTheOHLCVArrayReached === true + ) { /* We stop when the current candle is pointing to a time in the future.*/ - headOfTheMarketReached = true + savingProcedureFinished = true + /* + This will be our last file saved. + */ saveFile(currentDay) - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[INFO] start -> saveOHLCVs -> Before Fetch -> Saving OHLCVs @ " + processingDate + " -> i = " + i + " -> total = " + allOHLCVs.length) - TS.projects.superalgos.functionLibraries.processFunctions.processHeartBeat(processIndex, "Saving " + i.toFixed(0) + " / " + allOHLCVs.length + " OHLCVs from " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + " " + symbol + " @ " + processingDate) // tell the world we are alive and doing well + /* + We will produce our last log and heartbeat, since we have just + reached the head of the market. + */ + logAndHeartBeat() /* We exit the loop and we aint comming back*/ return } - let OHLCV = { // these values should be overrided unless there are no OHLVCs fetched from the exchange. + /* + We initialize here the OHLCV object. These initial + values should be overrided unless there are no + OHLVCs fetched from the exchange. We need the + timestamp in order to calculate OHLCVMinute. + */ + let OHLCV = { timestamp: (new Date()).valueOf() + TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS, open: 0, hight: 0, @@ -462,9 +524,16 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { volume: 0 } - let record = allOHLCVs[i] + let record = rawDataArray[ohlcvArrayIndex] - if (record !== undefined) { // can be undefined if there is no candle fetched from the exchange + /* + We will check that we can have a record to + analize. It might happen that we don't have one + in the situation that we could not get a single + record from the exchange. We still want to be + here so that everything is properly logged. + */ + if (record !== undefined) { OHLCV = { timestamp: record[0], open: record[1], @@ -477,48 +546,73 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { let candleMinute = Math.trunc(candle.begin / TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS) let OHLCVMinute + /* + Some exchanges return inconsistent data. It is not guaranteed + that each candle will have a timeStamp exactly at the begining of an + UTC minute. It is also not guaranteed that the distance + between timestamps will be the same. To fix this, we will do this. + */ - checkOHLCVMinute() + OHLCVMinute = Math.trunc(OHLCV.timestamp / TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS) - function checkOHLCVMinute() { - /* - Some exchanges return inconsistent data. It is not guaranteed that each candle will have a timeStamp exactly at the begining of an - UTC minute. It is also not guaranteed that the distance between timestamps will be the same. To fix this, we will do this. - */ + /* + If the minute of the record item received from the exchange is + less than the minute of the current minute in our loop, + that means that we need to reposition the inded at the rawDataArray + array, moving it one record fordward, and that is what we are + doing here. + */ + while (OHLCVMinute < candleMinute) { - OHLCVMinute = Math.trunc(OHLCV.timestamp / TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS) + /* Move fordward at the rawDataArray array. */ + ohlcvArrayIndex++ - if (OHLCVMinute < candleMinute) { - if (i >= allOHLCVs.length - 1) { - /* We run out of OHLCVs, we can not move to the next OHLCV, we leave this function. */ - return - } - - i++ - record = allOHLCVs[i] - OHLCV = { - timestamp: record[0], - open: record[1], - hight: record[2], - low: record[3], - close: record[4], - volume: record[5], - id: record[6] - } - setImmediate (checkOHLCVMinute) + /* Check that we have not passed the end of the array */ + if (ohlcvArrayIndex > rawDataArray.length - 1) { + /* + We run out of OHLCVs, we can not move to the next OHLCV, + we need to leave this loop. + */ + break } + + record = rawDataArray[ohlcvArrayIndex] + + /* + Once this loop is broken, this is the OHLCV that needs + to be considered. All the ones in the past are ignored. + */ + OHLCV = { + timestamp: record[0], + open: record[1], + hight: record[2], + low: record[3], + close: record[4], + volume: record[5], + id: record[6] + } + + /* Recalculate this to see if we need to break the loop*/ + OHLCVMinute = Math.trunc(OHLCV.timestamp / TS.projects.superalgos.globals.timeConstants.ONE_MIN_IN_MILISECONDS) } - /* Reporting we are doing well */ - heartBeatCounter-- - if (heartBeatCounter <= 0) { - heartBeatCounter = 1440 - TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[INFO] start -> saveOHLCVs -> After Fetch -> Saving OHLCVs @ " + processingDate + " -> i = " + i + " -> total = " + allOHLCVs.length) - TS.projects.superalgos.functionLibraries.processFunctions.processHeartBeat(processIndex, "Saving " + i.toFixed(0) + " / " + allOHLCVs.length + " OHLCVs from " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + " " + symbol + " @ " + processingDate) // tell the world we are alive and doing well - } - /* End Reporting */ + /* + If the candleMinute and the OHLCVMinute matches, then + we transfer the properties of the OHLCV into the + candle object and the volume object. Two things to + consider here: + 1. If they do not match, at this point it could only means + that the OHLCVMinute is in the future, in which case the + candle and volume will keep their initialization values + which in turn are equal to the latest candle and volumes. + + 2. They might be equal even though the OHLCV timestamp + did not match exactly the UTC minute, but since we are + comparing truncated values, then we force the matching + and we correct the shifting in time that sometimes happens + with exchange data. + */ if (candleMinute === OHLCVMinute) { candle.open = OHLCV.open candle.close = OHLCV.close @@ -527,14 +621,25 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { volume.buy = OHLCV.volume / 2 volume.sell = OHLCV.volume / 2 - if (i < allOHLCVs.length - 1) { - i++ + /* + Since we extracted this OHLCV value, we move + fordward our array index. + */ + if (ohlcvArrayIndex < rawDataArray.length - 1) { + ohlcvArrayIndex++ + } else { + endOfTheOHLCVArrayReached = true } lastId = OHLCV.id - } + + /* + Here we remeber the last candle and volumen, in case + we need it. + */ lastCandle = candle + lastVolume = volume if (needSeparator === false) { needSeparator = true; @@ -548,14 +653,40 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { volumesFileContent = volumesFileContent + separator + '[' + volume.buy + "," + volume.sell + "," + volume.begin + "," + volume.end + "]"; /* We store the last candle of the day in order to have a previous candles during next execution. */ - if (j === 1440 - 1) { + if (minuteOfTheDay === 1440 - 1) { lastCandleOfTheDay = JSON.parse(JSON.stringify(candle)) } + + /* Reporting we are doing well */ + heartBeatCounter-- + if (heartBeatCounter <= 0) { + heartBeatCounter = 1440 + logAndHeartBeat() + } + + function logAndHeartBeat() { + /* We need thi processing date for logging purposes only */ + let processingDate = new Date(candle.begin) + processingDate = + processingDate.getUTCFullYear() + '-' + + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processingDate.getUTCMonth() + 1, 2) + '-' + + TS.projects.superalgos.utilities.miscellaneousFunctions.pad(processingDate.getUTCDate(), 2); + + TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, + "[INFO] start -> saveOHLCVs -> Before Fetch -> Saving OHLCVs @ " + processingDate + " -> ohlcvArrayIndex = " + ohlcvArrayIndex + " -> total = " + rawDataArray.length) + TS.projects.superalgos.functionLibraries.processFunctions.processHeartBeat(processIndex, "Saving " + (ohlcvArrayIndex + 1).toFixed(0) + " / " + rawDataArray.length + " OHLCVs from " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + " " + symbol + " @ " + processingDate) // tell the world we are alive and doing well + } } - previousDay = currentDay - - if (i > 0) { // Only start saving at the day of the first candle. + /* + When the bot is processing historical information, it + happens that during the whole processing of one day + it did not reach either the head of the market (a future time) + nor the end of the Raw Data Array. In this situation + we still need to save the full day of content, and + we do it only if at least one candle has been processed. + */ + if (ohlcvArrayIndex > 0) { saveFile(currentDay) return } @@ -565,7 +696,7 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { function saveFile(day) { candlesFileContent = candlesFileContent + ']' volumesFileContent = volumesFileContent + ']' - + let fileName = 'Data.json' filesToCreate++ @@ -577,7 +708,6 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { candlesFileContent = '[' volumesFileContent = '[' needSeparator = false - } function onFileCreated(err) { @@ -605,39 +735,60 @@ exports.newSuperalgosBotModulesHistoricOHLCVs = function (processIndex) { } function controlLoop() { + /* + This loop advances one day, and if it does not need to stop + for any reason, it will execute the loop function so as to process + the next day. + */ + currentDay++ + + /* + It might have happened that the User is stopping the Task. If that + is the case, we need to stop this processing here. + */ if (TS.projects.superalgos.globals.taskVariables.IS_TASK_STOPPING === true) { callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE); return } + /* + If we had any problem saving the latest file, we will also abort + this process here, so that we can record our progress until it stopped + working. + */ if (error) { callBackFunction(error); return; } - currentDay++ - /* - One possible exit is when we reached the amount of candles downloaded. This not necesary happens at the end of the market - if the process was canceled for any reason at the middle. + One possible exit is when we reached the amount of candles downloaded. + This does not necesary happens at the end of the market + if the process was canceled for any reason at the middle, + or the exchange became unavailable. */ - - if (i >= allOHLCVs.length - 1) { + if (ohlcvArrayIndex >= rawDataArray.length - 1) { writeStatusReport() TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, - "[INFO] start -> saveOHLCVs -> controlLoop -> Exit because i reached the end of the candles array. ") + "[INFO] start -> saveOHLCVs -> controlLoop -> Exit because i reached the end of the rawDataArray array. ") return } - - /* The natural exit is at the end of the market */ - if (headOfTheMarketReached === false) { - setImmediate(loop) - } else { + /* + The most common exit is at the end of the market. There is + nothing else to save, so we finish here. + */ + if (savingProcedureFinished === true) { + writeStatusReport() TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[INFO] start -> saveOHLCVs -> controlLoop -> Exit because we reached the end of the market. ") - writeStatusReport() + return } + + /* + If there is no reson to exit, we will process the next day. + */ + setImmediate(loop) } } catch (err) { From f8c6b40c7c1bd77d0f0b46d75e8450c6ba96a05f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 21 Jan 2021 13:38:27 +0100 Subject: [PATCH 21/22] Bug Fix --- Client/httpInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 82729ce58..15d576987 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -611,7 +611,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE placeholder: {} } - respondWithDocsObject(docs, result.error) + respondWithDocsObject(docs, error) return } From 29614b96466341e2f2f8b9f5e223eef99bb1d3a9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 21 Jan 2021 13:52:44 +0100 Subject: [PATCH 22/22] Bug Fixed with # in commit message --- Client/httpInterface.js | 7 ++++++- .../Superalgos/UI/Spaces/Docs-Space/CommandInterface.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 15d576987..11e66375c 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -590,13 +590,18 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE switch (requestParameters[2]) { // switch by command case 'Contribute': { try { - const commitMessage = unescape(requestParameters[3]) + let commitMessage = unescape(requestParameters[3]) const username = unescape(requestParameters[4]) const token = unescape(requestParameters[5]) const currentBranch = unescape(requestParameters[6]) const contributionsBranch = unescape(requestParameters[7]) let error + /* Unsavping # */ + for (let i = 0; i < 10; i++) { + commitMessage = commitMessage.replace('HASHTAG', '#') + } + contribute() async function contribute() { diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index 63d712553..410c09784 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -65,7 +65,7 @@ function newSuperalgosDocsCommmandInterface() { httpRequest( undefined, 'App/Contribute/' + - message + '/' + + message.replaceAll('#', 'HASHTAG') + '/' + config.username + '/' + config.token + '/' + UI.projects.superalgos.spaces.docsSpace.currentBranch + '/' +