fix: handle empty history when deleting dg (#6)

This commit is contained in:
Sérgio Ramos 2017-09-18 21:49:10 +01:00 committed by Wyatt Preul
parent 37f2201923
commit ac2eab6cfe
2 changed files with 23 additions and 5 deletions

View File

@ -1,7 +1,5 @@
#import "./DeploymentGroupInfo.gql"
mutation DeleteDeploymentGroup($id: ID!) {
deleteDeploymentGroup(id: $id) {
...DeploymentGroupInfo
id
}
}

View File

@ -466,6 +466,10 @@ class Data extends EventEmitter {
return cb(err);
}
if (!deploymentGroup) {
return cb(null);
}
cb(null, Transform.fromDeploymentGroup(this._getDeploymentGroupFns(deploymentGroup)));
});
}
@ -545,7 +549,9 @@ class Data extends EventEmitter {
}, next);
}
]
}, cb);
}, (err) => {
cb(err, res.dg);
});
};
VAsync.parallel({
@ -695,7 +701,21 @@ class Data extends EventEmitter {
return finish(err);
}
this._db.versions.get(deploymentGroup.history, finish);
if (!deploymentGroup) {
return finish(null, []);
}
deploymentGroup.history({}, (err, history) => {
if (err) {
return finish(err);
}
if (!history.length) {
return finish(null, []);
}
this._db.versions.get(deploymentGroup.history.map(({ id }) => { return { id }; }), finish);
});
});
});
}