Query Types as Global Contants
This commit is contained in:
1 parent
b4d2a17f12
commit
3e079b21a7
12 files changed
+57
-45
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -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 }
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.')
|
||||
}
|
||||
|
||||
|
||||
File renamed without changes.
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user