mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-16 17:02:18 +00:00
Merge branch 'THI/sleep-dailies-fix' into release
This commit is contained in:
commit
a0f10cbf4b
2 changed files with 30 additions and 8 deletions
|
|
@ -313,6 +313,24 @@ describe('cron', () => {
|
|||
expect(tasksByType.dailys[0].completed).to.be.false;
|
||||
expect(user.stats.hp).to.equal(healthBefore);
|
||||
});
|
||||
|
||||
it('sets isDue for daily', () => {
|
||||
let daily = {
|
||||
text: 'test daily',
|
||||
type: 'daily',
|
||||
frequency: 'daily',
|
||||
everyX: 5,
|
||||
startDate: new Date(),
|
||||
};
|
||||
|
||||
let task = new Tasks.daily(Tasks.Task.sanitize(daily)); // eslint-disable-line new-cap
|
||||
tasksByType.dailys.push(task);
|
||||
tasksByType.dailys[0].completed = true;
|
||||
|
||||
cron({user, tasksByType, daysMissed, analytics});
|
||||
|
||||
expect(tasksByType.dailys[0].isDue).to.be.exist;
|
||||
});
|
||||
});
|
||||
|
||||
describe('todos', () => {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,16 @@ const i18n = common.i18n;
|
|||
const loginIncentives = common.content.loginIncentives;
|
||||
// const maxPMs = 200;
|
||||
|
||||
function setIsDueNextDue (task, user, now) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
export async function recoverCron (status, locals) {
|
||||
let {user} = locals;
|
||||
|
||||
|
|
@ -108,6 +118,7 @@ function performSleepTasks (user, tasksByType, now) {
|
|||
}
|
||||
|
||||
daily.completed = false;
|
||||
setIsDueNextDue(daily, user, now);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -316,14 +327,7 @@ export function cron (options = {}) {
|
|||
});
|
||||
task.completed = false;
|
||||
|
||||
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;
|
||||
}
|
||||
setIsDueNextDue(task, user, now);
|
||||
|
||||
if (completed || scheduleMisses > 0) {
|
||||
if (task.checklist) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue