Superalgos Network: Query User Profiles debugged

This commit is contained in:
Luis Fernando Molina committed 2021-09-03 12:23:42 +02:00
1 parent 2645df775e
commit 67ec986422
13 files changed
+266 -227

No files matched your search

@@ -21,8 +21,8 @@ exports.newSocialTradingModulesQueriesEvents = function newSocialTradingModulesQ
function initialize(queryReceived) {
NT.utilities.queriesValidations.profilesValidations(queryReceived, thisObject)
NT.utilities.queriesValidations.arrayValidations(queryReceived, thisObject)
NT.projects.socialTrading.utilities.queriesValidations.profilesValidations(queryReceived, thisObject)
NT.projects.socialTrading.utilities.queriesValidations.arrayValidations(queryReceived, thisObject, NT.memory.arrays.EVENTS)
}
@@ -8,6 +8,7 @@ exports.newSocialTradingModulesQueriesPostReplies = function newSocialTradingMod
of a certain post, with all its replies.
*/
let thisObject = {
array: undefined,
profile: undefined,
post: undefined,
initialIndex: undefined,
@@ -21,27 +22,30 @@ exports.newSocialTradingModulesQueriesPostReplies = function newSocialTradingMod
return thisObject
function finalize() {
thisObject.array = undefined
thisObject.profile = undefined
thisObject.post = undefined
}
function initialize(queryReceived) {
NT.utilities.queriesValidations.profilesValidations(queryReceived, thisObject)
NT.utilities.queriesValidations.postValidations(queryReceived, thisObject)
NT.utilities.queriesValidations.arrayValidations(queryReceived, thisObject)
thisObject.array = Array.from(thisObject.post.replies)
NT.projects.socialTrading.utilities.queriesValidations.profilesValidations(queryReceived, thisObject)
NT.projects.socialTrading.utilities.queriesValidations.postValidations(queryReceived, thisObject)
NT.projects.socialTrading.utilities.queriesValidations.arrayValidations(queryReceived, thisObject, thisObject.array)
}
function execute() {
let response = []
let array = Array.from(thisObject.post.replies)
switch (thisObject.direction) {
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let arrayItem = array[i]
let arrayItem = thisObject.array[i]
if (post === undefined) { break }
addToResponse(arrayItem)
}
@@ -49,7 +53,7 @@ exports.newSocialTradingModulesQueriesPostReplies = function newSocialTradingMod
}
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let arrayItem = array[i]
let arrayItem = thisObject.array[i]
if (post === undefined) { break }
addToResponse(arrayItem)
}
@@ -4,6 +4,7 @@ exports.newSocialTradingModulesQueriesProfileFollowers = function newSocialTradi
all the User or Bot profiles that are following a certain User or Bot profile.
*/
let thisObject = {
array: undefined,
profile: undefined,
initialIndex: undefined,
amountRequested: undefined,
@@ -16,25 +17,27 @@ exports.newSocialTradingModulesQueriesProfileFollowers = function newSocialTradi
return thisObject
function finalize() {
thisObject.array = undefined
thisObject.profile = undefined
}
function initialize(queryReceived) {
NT.utilities.queriesValidations.profilesValidations(queryReceived, thisObject)
NT.utilities.queriesValidations.arrayValidations(queryReceived, thisObject)
thisObject.array = Array.from(thisObject.profile.followers)
NT.projects.socialTrading.utilities.queriesValidations.profilesValidations(queryReceived, thisObject)
NT.projects.socialTrading.utilities.queriesValidations.arrayValidations(queryReceived, thisObject, thisObject.array)
}
function execute() {
let response = []
let array = Array.from(thisObject.profile.followers)
switch (thisObject.direction) {
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let arrayItem = array[i]
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
addToResponse(arrayItem)
}
@@ -42,7 +45,7 @@ exports.newSocialTradingModulesQueriesProfileFollowers = function newSocialTradi
}
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let arrayItem = array[i]
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
addToResponse(arrayItem)
}
@@ -4,6 +4,7 @@ exports.newSocialTradingModulesQueriesProfileFollowing = function newSocialTradi
all the User or Bot profiles that are being followed by a certain User or Bot profile.
*/
let thisObject = {
array: undefined,
profile: undefined,
initialIndex: undefined,
amountRequested: undefined,
@@ -16,25 +17,27 @@ exports.newSocialTradingModulesQueriesProfileFollowing = function newSocialTradi
return thisObject
function finalize() {
thisObject.array = undefined
thisObject.profile = undefined
}
function initialize(queryReceived) {
NT.utilities.queriesValidations.profilesValidations(queryReceived, thisObject)
NT.utilities.queriesValidations.arrayValidations(queryReceived, thisObject)
thisObject.array = Array.from(thisObject.profile.following)
NT.projects.socialTrading.utilities.queriesValidations.profilesValidations(queryReceived, thisObject)
NT.projects.socialTrading.utilities.queriesValidations.arrayValidations(queryReceived, thisObject, thisObject.array)
}
function execute() {
let response = []
let array = Array.from(thisObject.profile.following)
switch (thisObject.direction) {
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let arrayItem = array[i]
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
addToResponse(arrayItem)
}
@@ -42,7 +45,7 @@ exports.newSocialTradingModulesQueriesProfileFollowing = function newSocialTradi
}
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let arrayItem = array[i]
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
addToResponse(arrayItem)
}
@@ -8,6 +8,7 @@ exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradi
with all of its posts.
*/
let thisObject = {
array: undefined,
profile: undefined,
initialIndex: undefined,
amountRequested: undefined,
@@ -20,24 +21,26 @@ exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradi
return thisObject
function finalize() {
thisObject.array = undefined
thisObject.profile = undefined
}
function initialize(queryReceived) {
NT.utilities.queriesValidations.profilesValidations(queryReceived, thisObject)
NT.utilities.queriesValidations.arrayValidations(queryReceived, thisObject)
thisObject.array = Array.from(thisObject.profile.posts)
NT.projects.socialTrading.utilities.queriesValidations.profilesValidations(queryReceived, thisObject)
NT.projects.socialTrading.utilities.queriesValidations.arrayValidations(queryReceived, thisObject, thisObject.array)
}
function execute() {
let response = []
let array = Array.from(thisObject.profile.posts)
switch (thisObject.direction) {
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let arrayItem = array[i]
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
addToResponse(arrayItem)
}
@@ -45,7 +48,7 @@ exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradi
}
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let arrayItem = array[i]
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
addToResponse(arrayItem)
}
@@ -1,10 +1,11 @@
exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradingModulesQueriesUserProfileStats() {
exports.newSocialTradingModulesQueriesUserProfiles = function newSocialTradingModulesQueriesUserProfiles() {
/*
This query returns a list of user profiles ordered
by Ranking. It is useful to bootstrap new users
and provide them with alternative of who to follow.
*/
let thisObject = {
array: undefined,
initialIndex: undefined,
amountRequested: undefined,
direction: undefined,
@@ -16,24 +17,29 @@ exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradi
return thisObject
function finalize() {
thisObject.array = undefined
}
function initialize(queryReceived) {
NT.utilities.queriesValidations.arrayValidations(queryReceived, thisObject)
thisObject.array = Array.from(
NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID,
x => x[1]
)
thisObject.array.sort((a, b) => (a["ranking"] > b["ranking"]) ? 1 : -1)
NT.projects.socialTrading.utilities.queriesValidations.arrayValidations(queryReceived, thisObject, thisObject.array)
}
function execute() {
let response = []
let array = Array.from(NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID)
array.sort((a, b) => (a["ranking"].toLowerCase() > b["ranking"].toLowerCase()) ? 1 : -1)
switch (thisObject.direction) {
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let arrayItem = array[i]
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
addToResponse(arrayItem)
}
@@ -41,7 +47,7 @@ exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradi
}
case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let arrayItem = array[i]
let arrayItem = thisObject.array[i]
if (arrayItem === undefined) { break }
addToResponse(arrayItem)
}