v1.18.x
psychobunny 10 years ago
parent 7161972cc3
commit 4a9498e105

@ -15,7 +15,7 @@ rewards.save = function(data, callback) {
data.id = id; data.id = id;
async.waterfall([ async.series([
function(next) { function(next) {
rewards.delete(data, next); rewards.delete(data, next);
}, },
@ -97,7 +97,7 @@ function saveConditions(data, callback) {
db.setAdd('conditions:active', conditions, callback); db.setAdd('conditions:active', conditions, callback);
async.each(Object.keys(rewardsPerCondition), function(condition, next) { async.each(Object.keys(rewardsPerCondition), function(condition, next) {
db.setAdd('condition:' + condition + ':rewards', rewardsPerCondition[condition]); db.setAdd('condition:' + condition + ':rewards', rewardsPerCondition[condition], next);
}, callback); }, callback);
}); });
} }
@ -114,8 +114,10 @@ function getActiveRewards(callback) {
db.getObject('rewards:id:' + id + ':rewards', next); db.getObject('rewards:id:' + id + ':rewards', next);
} }
}, function(err, data) { }, function(err, data) {
data.main.rewards = data.rewards; if (data.main) {
activeRewards.push(data.main); data.main.rewards = data.rewards;
activeRewards.push(data.main);
}
next(err); next(err);
}); });

Loading…
Cancel
Save