From 41d68bcf014b561c5546ff0905e0729b053cd87b Mon Sep 17 00:00:00 2001 From: "mati108@gmail.com" <34651529+matbenitez@users.noreply.github.com> Date: Sat, 2 Feb 2019 11:39:42 -0300 Subject: [PATCH] Fixing execution summary update --- .../mutations/UpdateExecutionSummary.js | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/server/src/schema/mutations/UpdateExecutionSummary.js b/server/src/schema/mutations/UpdateExecutionSummary.js index 44c524e0b..1c889198d 100644 --- a/server/src/schema/mutations/UpdateExecutionSummary.js +++ b/server/src/schema/mutations/UpdateExecutionSummary.js @@ -13,6 +13,9 @@ import { import { Clone } from '../../models' import logger from '../../config/logger' import teamQuery from '../../graphQLCalls/teamQuery' +import cloneDetails from '../cloneDetails' +import removeKuberneteClone from '../../kubernetes/removeClone' +import { isDefined } from '../../config/utils' const args = { id: { type: new GraphQLNonNull(GraphQLID) }, @@ -45,10 +48,14 @@ const resolve = async (parent, active: true }) + if(!isDefined(clone)){ + return "Clone not found." + } + let team = await teamQuery(context.authorization, clone.teamId) clone = await cloneDetails(context.userId, team.data.data.teams_TeamById, clone) - logger.debug('removeClone -> Removing Clone from Kubernates.') + logger.debug('UpdateExecutionSummary -> Removing Clone from Kubernates.') await removeKuberneteClone(clone) const query = { _id: id } @@ -61,22 +68,24 @@ const resolve = async (parent, combinedProfitsA: combinedProfitsA, combinedProfitsB: combinedProfitsB, assetA: assetA, - assetB: assetB + assetB: assetB, + active: false } - await Clone.update(query, update, (err) => { + logger.debug('UpdateExecutionSummary -> Updating clone on database.') + await Clone.update(query, update, options, (err, clone) => { if (err){ logger.error('Error updating execution summary on the database. %s', err.stack) - throw new OperationsError(err.message) + throw err } else { logger.debug('Execution summary updated.') sucessful = true } }) - if(sucessful){ + if(sucessful) return 'Execution summary updated.' - } + } catch (error) { logger.error('Error updating the execution summary. %s', error.stack) throw new OperationsError(error.message)