Adding support for multiple bot execution
This commit is contained in:
1 parent
709a6cb770
commit
2cda4ad606
14 files changed
+74
-81
No files matched your search
@@ -5,7 +5,6 @@ import { AutorizationError } from '../errors'
|
||||
const cloneDetails = async(authId, team, clone) => {
|
||||
logger.debug('Retrieving clone details.')
|
||||
|
||||
// TODO Pending improvement by authorization module
|
||||
if(!(authId === process.env.AACLOUD_ID || isAuthorized(team, authId))){
|
||||
logger.debug('User %s is not authorized to manage team %s.', authId, team.slug )
|
||||
throw new AutorizationError()
|
||||
@@ -17,7 +16,6 @@ const cloneDetails = async(authId, team, clone) => {
|
||||
clone.kind = selectedBot.kind
|
||||
clone.teamSlug = team.slug
|
||||
clone.botSlug = selectedBot.slug
|
||||
clone.cloneName = (clone.teamSlug + '-' + clone.botSlug + '-' + clone.mode).toLowerCase()
|
||||
clone.teamName = team.name
|
||||
clone.botName = selectedBot.name
|
||||
clone.botAvatar = selectedBot.avatar
|
||||
|
||||
@@ -35,20 +35,6 @@ const resolve = async(parent, { clone }, context) => {
|
||||
throw new WrongArgumentsError('The bot type selected is not valid.')
|
||||
}
|
||||
|
||||
let existingClone = await Clone.find(
|
||||
{
|
||||
authId: context.userId,
|
||||
mode: clone.mode,
|
||||
botId: clone.botId,
|
||||
active: true
|
||||
})
|
||||
|
||||
logger.debug('addClone -> Checking existing clone.')
|
||||
if(existingClone.length > 0){
|
||||
throw new OperationsError('You can only have one active clone by mode. Remove the'
|
||||
+ ' existing clone of type: ' + clone.mode + ' and try again.')
|
||||
}
|
||||
|
||||
try{
|
||||
let team = await teamQuery(context.authorization, clone.teamId)
|
||||
clone = await cloneDetails(context.userId, team.data.data.teams_TeamById, clone)
|
||||
|
||||
@@ -30,11 +30,12 @@ const resolve = async(parent, args, context) => {
|
||||
}).sort({createDatetime: -1})
|
||||
|
||||
for (var i = 0; i < clones.length; i++) {
|
||||
logger.debug('List Clones -> clone: %j',clones[i] )
|
||||
let team = await teamQuery(context.authorization, clones[i].teamId)
|
||||
clones[i] = await cloneDetails(context.userId, team.data.data.teams_TeamById, clones[i])
|
||||
let state = await getCloneStatus(clones[i].cloneName)
|
||||
let state = await getCloneStatus(clones[i].id)
|
||||
clones[i].state = state.substring(1, state.length-1)
|
||||
let lastLogs = await getCloneLogs(clones[i].cloneName)
|
||||
let lastLogs = await getCloneLogs(clones[i].id)
|
||||
clones[i].lastLogs = lastLogs.substring(1, lastLogs.length-1)
|
||||
clones[i].botType = clones[i].kind // Only for listing we show the teams value
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ const CloneType = new GraphQLObjectType({
|
||||
createDatetime: {type: GraphQLInt},
|
||||
lastLogs: {type: GraphQLString},
|
||||
runAsTeam: {type: GraphQLBoolean},
|
||||
processName: { type: GraphQLString },
|
||||
summaryDate: {type: GraphQLInt},
|
||||
buyAverage: {type: GraphQLFloat},
|
||||
sellAverage: {type: GraphQLFloat},
|
||||
|
||||
@@ -22,7 +22,7 @@ const Type = new GraphQLInputObjectType({
|
||||
endYear: { type: GraphQLInt },
|
||||
month: { type: GraphQLInt },
|
||||
interval: { type: GraphQLInt },
|
||||
processName: { type: GraphQLString },
|
||||
processName: { type: new GraphQLNonNull(GraphQLString) },
|
||||
botType: { type: new GraphQLNonNull(GraphQLString) }
|
||||
})
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user