Fix platform update logic

This commit is contained in:
Girish Ramakrishnan
2019-09-24 20:29:01 -07:00
parent 00fd9e5b7f
commit 85c13cae58
9 changed files with 80 additions and 50 deletions
+6 -4
View File
@@ -454,16 +454,18 @@ function setHealth(appId, health, healthTime, callback) {
updateWithConstraints(appId, values, '', callback);
}
function setTask(appId, values, requiredState, callback) {
function setTask(appId, values, options, callback) {
assert.strictEqual(typeof appId, 'string');
assert.strictEqual(typeof values, 'object');
assert(requiredState === null || typeof requiredState === 'string');
assert.strictEqual(typeof options, 'object');
assert.strictEqual(typeof callback, 'function');
if (requiredState === null) {
if (!options.requireNullTaskId) return updateWithConstraints(appId, values, '', callback);
if (options.requiredState === null) {
updateWithConstraints(appId, values, 'AND taskId IS NULL', callback);
} else {
updateWithConstraints(appId, values, `AND taskId IS NULL AND installationState = "${requiredState}"`, callback);
updateWithConstraints(appId, values, `AND taskId IS NULL AND installationState = "${options.requiredState}"`, callback);
}
}