mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
more bug-fixing on async cron, using lodash instead of underscore
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
var MODIFIER, async, content, cron, expModifier, helpers, hpModifier, model, moment, score, setModel, setupNotifications, updateStats, user;
|
||||
var MODIFIER, async, content, cron, expModifier, helpers, hpModifier, model, moment, score, setModel, setupNotifications, updateStats, user, _;
|
||||
|
||||
async = require('async');
|
||||
|
||||
moment = require('moment');
|
||||
|
||||
_ = require('lodash');
|
||||
|
||||
content = require('./content');
|
||||
|
||||
helpers = require('./helpers');
|
||||
@@ -166,7 +168,7 @@ score = function(taskId, direction, options) {
|
||||
if (type === 'habit') {
|
||||
if (taskObj.value !== value) {
|
||||
task.push('history', {
|
||||
date: moment().sod().toDate(),
|
||||
date: moment().toDate(),
|
||||
value: value
|
||||
});
|
||||
}
|
||||
@@ -206,7 +208,7 @@ cron = function() {
|
||||
if (daysPassed > 0) {
|
||||
todoTally = 0;
|
||||
tallyTask = function(taskObj, next) {
|
||||
var absVal, completed, dayMapping, daysFailed, dueToday, id, repeat, task, type, value;
|
||||
var absVal, completed, dayMapping, daysFailed, id, repeat, task, type, value;
|
||||
id = taskObj.id, type = taskObj.type, completed = taskObj.completed, repeat = taskObj.repeat;
|
||||
if (id == null) {
|
||||
return;
|
||||
@@ -226,9 +228,16 @@ cron = function() {
|
||||
6: 's',
|
||||
7: 'su'
|
||||
};
|
||||
dueToday = repeat && repeat[dayMapping[momentDate.day()]] === true;
|
||||
daysFailed = 0;
|
||||
_.times(daysPassed, function(n) {
|
||||
var thatDay;
|
||||
thatDay = today.subtract('days', n + 1);
|
||||
if (repeat[dayMapping[thatDay.day()]] === true) {
|
||||
return daysFailed++;
|
||||
}
|
||||
});
|
||||
}
|
||||
score(taskId, 'down', {
|
||||
score(id, 'down', {
|
||||
cron: true,
|
||||
times: daysFailed
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user