Merge remote-tracking branch 'TheHollidayInn/yesterdailies-2' into release

This commit is contained in:
SabreCat
2017-07-05 20:04:26 +00:00
28 changed files with 321 additions and 109 deletions
+3 -1
View File
@@ -85,8 +85,10 @@ export function startOfDay (options = {}) {
export function daysSince (yesterday, options = {}) {
let o = sanitizeOptions(options);
let startOfNow = startOfDay(defaults({ now: o.now }, o));
let startOfYesterday = startOfDay(defaults({ now: yesterday }, o));
return startOfDay(defaults({ now: o.now }, o)).diff(startOfDay(defaults({ now: yesterday }, o)), 'days');
return startOfNow.diff(startOfYesterday, 'days');
}
/*
+5 -2
View File
@@ -1,6 +1,7 @@
import {
shouldDo,
} from '../cron';
import moment from 'moment';
/*
Task classes given everything about the class
@@ -8,7 +9,7 @@ Task classes given everything about the class
// TODO move to the client
module.exports = function taskClasses (task, filters = [], dayStart = 0, lastCron = Number(new Date()), showCompleted = false, main = false) {
module.exports = function taskClasses (task, filters = [], dayStart = 0, lastCron = Number(new Date()), showCompleted = false, main = false, processingYesterdailies = false) {
if (!task) {
return '';
}
@@ -34,7 +35,9 @@ module.exports = function taskClasses (task, filters = [], dayStart = 0, lastCro
}
if (type === 'todo' || type === 'daily') {
let notDue = !shouldDo(Number(new Date()), task, { dayStart });
let dayShouldDo = moment();
if (processingYesterdailies) dayShouldDo.subtract(1, 'days');
let notDue = !shouldDo(Number(dayShouldDo), task, { dayStart });
let isNotDueDaily = type === 'daily' && notDue;
if (completed || isNotDueDaily) {
@@ -25,6 +25,7 @@ module.exports = function taskDefaults (task = {}) {
challenge: {
shortName: 'None',
},
yesterDaily: true,
reminders: [],
attribute: 'str',
createdAt: new Date(), // TODO these are going to be overwritten by the server...