From b4d2a17f126ce9fa4e1f1b85b4dfe3c436a8a77b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 3 Sep 2021 12:47:33 +0200 Subject: [PATCH 1/3] Test Query User Profile Stats debugged --- Desktop/DesktopApp.js | 46 +++++++++++++++---- .../NT/Modules/ClientInterface.js | 1 - 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/Desktop/DesktopApp.js b/Desktop/DesktopApp.js index 19b8726a0..ab63aee68 100644 --- a/Desktop/DesktopApp.js +++ b/Desktop/DesktopApp.js @@ -17,8 +17,12 @@ exports.newDesktopApp = function newDesktopApp() { DK.webSocketsClient = SA.projects.network.modules.webSocketsClient.newNetworkModulesWebSocketsClient() await DK.webSocketsClient.initialize() - let queryMessage = { - equeryId: "123", + let queryMessage + let query + /* + Test Query User Profiles. + */ + queryMessage = { queryType: 0, emitterUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID, initialIndex: 'Last', @@ -26,21 +30,47 @@ exports.newDesktopApp = function newDesktopApp() { direction: 'Past' } - let query = { + query = { requestType: 'Query', - queryMessage : JSON.stringify(queryMessage ) + queryMessage: JSON.stringify(queryMessage) } await DK.webSocketsClient.sendMessage( JSON.stringify(query) ) - .then(showProfiles) - .catch(onError) - - function showProfiles(profiles){ + .then(showProfiles) + .catch(onError) + + function showProfiles(profiles) { console.log(profiles) } + /* + Test Query User Profile Stats. + */ + queryMessage = { + queryType: 1, + emitterUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID, + targetUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID + } + query = { + requestType: 'Query', + queryMessage: JSON.stringify(queryMessage) + } + + await DK.webSocketsClient.sendMessage( + JSON.stringify(query) + ) + .then(showProfilesStats) + .catch(onError) + + function showProfilesStats(profile) { + console.log(profile) + } + + /* + Error Handling + */ function onError(errorMessage) { console.log('[ERROR] Query not executed. ' + errorMessage) } diff --git a/Projects/Social-Trading/NT/Modules/ClientInterface.js b/Projects/Social-Trading/NT/Modules/ClientInterface.js index 9a0e7b57f..b74c0b675 100644 --- a/Projects/Social-Trading/NT/Modules/ClientInterface.js +++ b/Projects/Social-Trading/NT/Modules/ClientInterface.js @@ -145,7 +145,6 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule We expect here a JSON string with some or all of the following properties: { - "equeryId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", "queryType": 10, "emitterUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", "targetUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", From 3e079b21a7f965ef19f102b8cd1e3396f3e43ee8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 3 Sep 2021 13:08:57 +0200 Subject: [PATCH 2/3] Query Types as Global Contants --- Desktop/DesktopApp.js | 4 +-- Projects/ProjectsSchema.json | 22 ++++++++++---- .../NT/Modules/Queries/Events.js | 4 +-- .../NT/Modules/Queries/PostReplies.js | 4 +-- .../NT/Modules/Queries/ProfileFollowers.js | 2 +- .../NT/Modules/Queries/ProfileFollowing.js | 4 +-- .../NT/Modules/Queries/ProfilePosts.js | 4 +-- .../NT/Modules/Queries/UserProfiles.js | 4 +-- Projects/Social-Trading/NT/Modules/Query.js | 29 +++++-------------- .../NT/Utilities/QueriesValidations.js | 10 +++---- .../{NT => SA}/Globals/QueryConstants.js | 0 .../Social-Trading/SA/Globals/QueryTypes.js | 15 ++++++++++ 12 files changed, 57 insertions(+), 45 deletions(-) rename Projects/Social-Trading/{NT => SA}/Globals/QueryConstants.js (100%) create mode 100644 Projects/Social-Trading/SA/Globals/QueryTypes.js diff --git a/Desktop/DesktopApp.js b/Desktop/DesktopApp.js index ab63aee68..8e0b948fb 100644 --- a/Desktop/DesktopApp.js +++ b/Desktop/DesktopApp.js @@ -23,7 +23,7 @@ exports.newDesktopApp = function newDesktopApp() { Test Query User Profiles. */ queryMessage = { - queryType: 0, + queryType: SA.projects.socialTrading.globals.queryTypes.USER_PROFILES, emitterUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID, initialIndex: 'Last', amountRequested: 10, @@ -48,7 +48,7 @@ exports.newDesktopApp = function newDesktopApp() { Test Query User Profile Stats. */ queryMessage = { - queryType: 1, + queryType: SA.projects.socialTrading.globals.queryTypes.USER_PROFILE_STATS, emitterUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID, targetUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID } diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index f1bac7bfd..6cc52d73f 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -1306,12 +1306,6 @@ "propertyName": "socialTrading", "NT": { "globals": [ - { - "name": "Query Constants", - "propertyName": "queryConstants", - "functionName": "newSocialTradingGlobalsQueryConstants", - "fileName": "QueryConstants.js" - }, { "name": "Memory", "propertyName": "memory", @@ -1431,6 +1425,22 @@ "fileName": "QueriesValidations.js" } ] + }, + "SA": { + "globals": [ + { + "name": "Query Constants", + "propertyName": "queryConstants", + "functionName": "newSocialTradingGlobalsQueryConstants", + "fileName": "QueryConstants.js" + }, + { + "name": "Query Types", + "propertyName": "queryTypes", + "functionName": "newSocialTradingGlobalsQueryTypes", + "fileName": "QueryTypes.js" + } + ] } } ] \ No newline at end of file diff --git a/Projects/Social-Trading/NT/Modules/Queries/Events.js b/Projects/Social-Trading/NT/Modules/Queries/Events.js index 981cb9323..1732fe794 100644 --- a/Projects/Social-Trading/NT/Modules/Queries/Events.js +++ b/Projects/Social-Trading/NT/Modules/Queries/Events.js @@ -29,7 +29,7 @@ exports.newSocialTradingModulesQueriesEvents = function newSocialTradingModulesQ function execute() { let response = [] switch (thisObject.direction) { - case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { + case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) { let event = NT.memory.arrays.EVENTS[i] if (event === undefined) { break } @@ -37,7 +37,7 @@ exports.newSocialTradingModulesQueriesEvents = function newSocialTradingModulesQ } break } - case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { + case SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) { let event = NT.memory.arrays.EVENTS[i] if (event === undefined) { break } diff --git a/Projects/Social-Trading/NT/Modules/Queries/PostReplies.js b/Projects/Social-Trading/NT/Modules/Queries/PostReplies.js index 3a18bc421..d9af6ea72 100644 --- a/Projects/Social-Trading/NT/Modules/Queries/PostReplies.js +++ b/Projects/Social-Trading/NT/Modules/Queries/PostReplies.js @@ -43,7 +43,7 @@ exports.newSocialTradingModulesQueriesPostReplies = function newSocialTradingMod switch (thisObject.direction) { - case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { + case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) { let arrayItem = thisObject.array[i] if (post === undefined) { break } @@ -51,7 +51,7 @@ exports.newSocialTradingModulesQueriesPostReplies = function newSocialTradingMod } break } - case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { + case SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) { let arrayItem = thisObject.array[i] if (post === undefined) { break } diff --git a/Projects/Social-Trading/NT/Modules/Queries/ProfileFollowers.js b/Projects/Social-Trading/NT/Modules/Queries/ProfileFollowers.js index dccdcfd2d..ce9ba104d 100644 --- a/Projects/Social-Trading/NT/Modules/Queries/ProfileFollowers.js +++ b/Projects/Social-Trading/NT/Modules/Queries/ProfileFollowers.js @@ -35,7 +35,7 @@ exports.newSocialTradingModulesQueriesProfileFollowers = function newSocialTradi let response = [] switch (thisObject.direction) { - case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { + case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) { let arrayItem = thisObject.array[i] if (arrayItem === undefined) { break } diff --git a/Projects/Social-Trading/NT/Modules/Queries/ProfileFollowing.js b/Projects/Social-Trading/NT/Modules/Queries/ProfileFollowing.js index a1624dedb..a04791cac 100644 --- a/Projects/Social-Trading/NT/Modules/Queries/ProfileFollowing.js +++ b/Projects/Social-Trading/NT/Modules/Queries/ProfileFollowing.js @@ -35,7 +35,7 @@ exports.newSocialTradingModulesQueriesProfileFollowing = function newSocialTradi let response = [] switch (thisObject.direction) { - case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { + case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) { let arrayItem = thisObject.array[i] if (arrayItem === undefined) { break } @@ -43,7 +43,7 @@ exports.newSocialTradingModulesQueriesProfileFollowing = function newSocialTradi } break } - case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { + case SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) { let arrayItem = thisObject.array[i] if (arrayItem === undefined) { break } diff --git a/Projects/Social-Trading/NT/Modules/Queries/ProfilePosts.js b/Projects/Social-Trading/NT/Modules/Queries/ProfilePosts.js index 45ab02b3b..a1971be61 100644 --- a/Projects/Social-Trading/NT/Modules/Queries/ProfilePosts.js +++ b/Projects/Social-Trading/NT/Modules/Queries/ProfilePosts.js @@ -38,7 +38,7 @@ exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradi let response = [] switch (thisObject.direction) { - case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { + case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) { let arrayItem = thisObject.array[i] if (arrayItem === undefined) { break } @@ -46,7 +46,7 @@ exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradi } break } - case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { + case SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) { let arrayItem = thisObject.array[i] if (arrayItem === undefined) { break } diff --git a/Projects/Social-Trading/NT/Modules/Queries/UserProfiles.js b/Projects/Social-Trading/NT/Modules/Queries/UserProfiles.js index f90ef2f7d..bf5223624 100644 --- a/Projects/Social-Trading/NT/Modules/Queries/UserProfiles.js +++ b/Projects/Social-Trading/NT/Modules/Queries/UserProfiles.js @@ -37,7 +37,7 @@ exports.newSocialTradingModulesQueriesUserProfiles = function newSocialTradingMo let response = [] switch (thisObject.direction) { - case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { + case SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) { let arrayItem = thisObject.array[i] if (arrayItem === undefined) { break } @@ -45,7 +45,7 @@ exports.newSocialTradingModulesQueriesUserProfiles = function newSocialTradingMo } break } - case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { + case SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) { let arrayItem = thisObject.array[i] if (arrayItem === undefined) { break } diff --git a/Projects/Social-Trading/NT/Modules/Query.js b/Projects/Social-Trading/NT/Modules/Query.js index a45835cad..d60f1e998 100644 --- a/Projects/Social-Trading/NT/Modules/Query.js +++ b/Projects/Social-Trading/NT/Modules/Query.js @@ -15,19 +15,6 @@ exports.newSocialTradingModulesQuery = function newSocialTradingModulesQuery() { finalize: finalize } - const QUERY_TYPES = { - - USER_PROFILES: 0, - USER_PROFILE_STATS: 1, - BOT_PROFILE_STATS: 2, - PROFILE_POSTS: 3, - PROFILE_FOLLOWERS: 4, - PROFILE_FOLLOWING: 5, - POST_REPLIES: 6, - EVENTS: 7 - - } - return thisObject function finalize() { @@ -41,49 +28,49 @@ exports.newSocialTradingModulesQuery = function newSocialTradingModulesQuery() { switch (thisObject.queryType) { - case QUERY_TYPES.USER_PROFILES: { + case SA.projects.socialTrading.globals.queryTypes.USER_PROFILES: { thisObject.query = NT.projects.socialTrading.modules.queriesUserProfiles.newSocialTradingModulesQueriesUserProfiles() thisObject.query.initialize(queryReceived) break } - case QUERY_TYPES.USER_PROFILE_STATS: { + case SA.projects.socialTrading.globals.queryTypes.USER_PROFILE_STATS: { thisObject.query = NT.projects.socialTrading.modules.queriesUserProfileStats.newSocialTradingModulesQueriesUserProfileStats() thisObject.query.initialize(queryReceived) break } - case QUERY_TYPES.BOT_PROFILE_STATS: { + case SA.projects.socialTrading.globals.queryTypes.BOT_PROFILE_STATS: { thisObject.query = NT.projects.socialTrading.modules.queriesBotProfileStats.newSocialTradingModulesQueriesBotProfileStats() thisObject.query.initialize(queryReceived) break } - case QUERY_TYPES.PROFILE_POSTS: { + case SA.projects.socialTrading.globals.queryTypes.PROFILE_POSTS: { thisObject.query = NT.projects.socialTrading.modules.queriesProfilePosts.newSocialTradingModulesQueriesProfilePosts() thisObject.query.initialize(queryReceived) break } - case QUERY_TYPES.POST_REPLIES: { + case SA.projects.socialTrading.globals.queryTypes.POST_REPLIES: { thisObject.query = NT.projects.socialTrading.modules.queriesPostReplies.newSocialTradingModulesQueriesPostReplies() thisObject.query.initialize(queryReceived) break } - case QUERY_TYPES.PROFILE_FOLLOWERS: { + case SA.projects.socialTrading.globals.queryTypes.PROFILE_FOLLOWERS: { thisObject.query = NT.projects.socialTrading.modules.queriesProfileFollowers.newSocialTradingModulesQueriesProfileFollowers() thisObject.query.initialize(queryReceived) break } - case QUERY_TYPES.PROFILE_FOLLOWING: { + case SA.projects.socialTrading.globals.queryTypes.PROFILE_FOLLOWING: { thisObject.query = NT.projects.socialTrading.modules.queriesProfileFollowing.newSocialTradingModulesQueriesProfileFollowing() thisObject.query.initialize(queryReceived) break } - case QUERY_TYPES.maps.EVENTS: { + case SA.projects.socialTrading.globals.queryTypes.maps.EVENTS: { thisObject.query = NT.projects.socialTrading.modules.queriesEvents.newSocialTradingModulesQueriesEvents() thisObject.query.initialize(queryReceived) break diff --git a/Projects/Social-Trading/NT/Utilities/QueriesValidations.js b/Projects/Social-Trading/NT/Utilities/QueriesValidations.js index 20c00c0cf..dd63209ae 100644 --- a/Projects/Social-Trading/NT/Utilities/QueriesValidations.js +++ b/Projects/Social-Trading/NT/Utilities/QueriesValidations.js @@ -51,11 +51,11 @@ exports.newSocialTradingUtilitiesQueriesValidations = function newSocialTradingU throw ('Initial Index Undefined.') } - if (queryReceived.initialIndex === NT.projects.socialTrading.globals.queryConstants.INITIAL_INDEX_LAST) { + if (queryReceived.initialIndex === SA.projects.socialTrading.globals.queryConstants.INITIAL_INDEX_LAST) { queryReceived.initialIndex = array.length - 1 } - if (queryReceived.initialIndex === NT.projects.socialTrading.globals.queryConstants.INITIAL_INDEX_FIRST) { + if (queryReceived.initialIndex === SA.projects.socialTrading.globals.queryConstants.INITIAL_INDEX_FIRST) { queryReceived.initialIndex = 0 } @@ -75,11 +75,11 @@ exports.newSocialTradingUtilitiesQueriesValidations = function newSocialTradingU throw ('Amount Requested Is Not a Number.') } - if (queryReceived.amountRequested < NT.projects.socialTrading.globals.queryConstants.MIN_AMOUNT_REQUESTED) { + if (queryReceived.amountRequested < SA.projects.socialTrading.globals.queryConstants.MIN_AMOUNT_REQUESTED) { throw ('Amount Requested Below Min.') } - if (queryReceived.amountRequested > NT.projects.socialTrading.globals.queryConstants.MAX_AMOUNT_REQUESTED) { + if (queryReceived.amountRequested > SA.projects.socialTrading.globals.queryConstants.MAX_AMOUNT_REQUESTED) { throw ('Amount Requested Above Max.') } @@ -91,7 +91,7 @@ exports.newSocialTradingUtilitiesQueriesValidations = function newSocialTradingU throw ('Direction Undefined.') } - if (queryReceived.direction !== NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE && queryReceived.direction !== NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST) { + if (queryReceived.direction !== SA.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE && queryReceived.direction !== SA.projects.socialTrading.globals.queryConstants.DIRECTION_PAST) { throw ('Direction Not Supported.') } diff --git a/Projects/Social-Trading/NT/Globals/QueryConstants.js b/Projects/Social-Trading/SA/Globals/QueryConstants.js similarity index 100% rename from Projects/Social-Trading/NT/Globals/QueryConstants.js rename to Projects/Social-Trading/SA/Globals/QueryConstants.js diff --git a/Projects/Social-Trading/SA/Globals/QueryTypes.js b/Projects/Social-Trading/SA/Globals/QueryTypes.js new file mode 100644 index 000000000..ec010b230 --- /dev/null +++ b/Projects/Social-Trading/SA/Globals/QueryTypes.js @@ -0,0 +1,15 @@ +exports.newSocialTradingGlobalsQueryTypes = function () { + + let thisObject = { + USER_PROFILES: 0, + USER_PROFILE_STATS: 1, + BOT_PROFILE_STATS: 2, + PROFILE_POSTS: 3, + PROFILE_FOLLOWERS: 4, + PROFILE_FOLLOWING: 5, + POST_REPLIES: 6, + EVENTS: 7 + } + + return thisObject +} \ No newline at end of file From b7535dd7795a603c41d46f6688b4210100bb4abe Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 3 Sep 2021 14:57:37 +0200 Subject: [PATCH 3/3] Platform Bug Fixed: CLIENT_WEB_SOCKETS_INTERFACE_PORT not correctly refactored. --- Projects/Foundations/TS/Task-Modules/EventServerClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Foundations/TS/Task-Modules/EventServerClient.js b/Projects/Foundations/TS/Task-Modules/EventServerClient.js index 098dc85f2..c1de5323b 100644 --- a/Projects/Foundations/TS/Task-Modules/EventServerClient.js +++ b/Projects/Foundations/TS/Task-Modules/EventServerClient.js @@ -24,7 +24,7 @@ host = 'localhost' } if (port === undefined) { - port = global.env.WEB_SOCKETS_INTERFACE_PORT + port = global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT } let messageCounter = 0