Tasks is due (#8711)

* Added isDue field and isDue set on create

* Added isDue update on update task

* Add isdue calc to score task

* Added isdue calc to cron

* Fixed lint issue

* Added isDue to no set and updated grammar
This commit is contained in:
Keith Holliday
2017-05-10 07:40:45 -06:00
committed by GitHub
parent 638c9dee89
commit 727cdc9402
8 changed files with 34 additions and 1 deletions

View File

@@ -431,6 +431,7 @@ api.updateTask = {
} else if (task.userId !== user._id) { // If the task is owned by a user make it's the current one
throw new NotFound(res.t('taskNotFound'));
}
let oldCheckList = task.checklist;
// we have to convert task to an object because otherwise things don't get merged correctly. Bad for performances?
let [updatedTaskObj] = common.ops.updateTask(task.toObject(), req);
@@ -455,6 +456,10 @@ api.updateTask = {
task.group.approval.required = true;
}
if (sanitizedObj.type === 'daily') {
task.isDue = common.shouldDo(Date.now(), sanitizedObj, user.preferences);
}
let savedTask = await task.save();
if (group && task.group.id && task.group.assignedUsers.length > 0) {
@@ -584,6 +589,10 @@ api.scoreTask = {
}
}
if (task.type === 'daily') {
task.isDue = common.shouldDo(Date.now(), task, user.preferences);
}
let results = await Bluebird.all([
user.save(),
task.save(),