mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
try using "for in []" isntead of underscore for cron debugging
This commit is contained in:
@@ -504,32 +504,35 @@ ready(function(model) {
|
||||
});
|
||||
expTally = user.get('stats.exp');
|
||||
lvl = 0;
|
||||
_(user.get('stats.lvl') - 1).times(function() {
|
||||
while (lvl < (user.get('stats.lvl') - 1)) {
|
||||
lvl++;
|
||||
return expTally += 50 * Math.pow(lvl, 2) - 150 * lvl + 200;
|
||||
});
|
||||
expTally += 50 * Math.pow(lvl, 2) - 150 * lvl + 200;
|
||||
}
|
||||
return model.push('_user.history.exp', {
|
||||
date: new Date(),
|
||||
value: expTally
|
||||
});
|
||||
};
|
||||
exports.poormanscron = poormanscron = function() {
|
||||
var DAY, daysPassed, lastCron, today;
|
||||
var DAY, daysPassed, lastCron, n, today, _k, _results;
|
||||
model.setNull('_user.lastCron', new Date());
|
||||
lastCron = new Date((new Date(model.get('_user.lastCron'))).toDateString());
|
||||
today = new Date((new Date).toDateString());
|
||||
DAY = 1000 * 60 * 60 * 24;
|
||||
daysPassed = Math.floor((today.getTime() - lastCron.getTime()) / DAY);
|
||||
if (daysPassed > 0) {
|
||||
_(daysPassed).times(function() {
|
||||
return endOfDayTally();
|
||||
});
|
||||
model.set('_user.lastCron', today);
|
||||
return console.log({
|
||||
today: today,
|
||||
lastCron: lastCron,
|
||||
daysPassed: daysPassed
|
||||
}, 'cron debugging');
|
||||
_results = [];
|
||||
for (n = _k = 1; 1 <= daysPassed ? _k <= daysPassed : _k >= daysPassed; n = 1 <= daysPassed ? ++_k : --_k) {
|
||||
console.log({
|
||||
today: today,
|
||||
lastCron: lastCron,
|
||||
daysPassed: daysPassed,
|
||||
n: n
|
||||
}, "[debug] Cron (" + today + ", " + n + ")");
|
||||
_results.push(endOfDayTally());
|
||||
}
|
||||
return _results;
|
||||
}
|
||||
};
|
||||
poormanscron();
|
||||
|
||||
Reference in New Issue
Block a user