Added nextDue field

This commit is contained in:
Keith Holliday
2017-05-11 13:11:16 -06:00
parent e7418472f6
commit 1292f9a3d5
9 changed files with 63 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ import { model as User } from '../models/user';
import common from '../../common/';
import { preenUserHistory } from '../libs/preening';
import _ from 'lodash';
import cloneDeep from 'lodash/cloneDeep';
import nconf from 'nconf';
const CRON_SAFE_MODE = nconf.get('CRON_SAFE_MODE') === 'true';
@@ -314,7 +315,15 @@ export function cron (options = {}) {
value: task.value,
});
task.completed = false;
task.isDue = common.shouldDo(Date.now(), task, user.preferences);
let optionsForShouldDo = cloneDeep(user.preferences.toObject());
task.isDue = common.shouldDo(now, task, optionsForShouldDo);
optionsForShouldDo.nextDue = true;
let nextDue = common.shouldDo(now, task, optionsForShouldDo);
if (nextDue && nextDue.length > 0) {
task.nextDue = nextDue;
}
if (completed || scheduleMisses > 0) {
if (task.checklist) {