mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
26 lines
687 B
JavaScript
26 lines
687 B
JavaScript
import _ from 'lodash';
|
|
import preenHistory from '../libs/preenHistory';
|
|
|
|
module.exports = function(user, minHistLen) {
|
|
if (minHistLen == null) {
|
|
minHistLen = 7;
|
|
}
|
|
_.each(user.habits.concat(user.dailys), function(task) {
|
|
var ref;
|
|
if (((ref = task.history) != null ? ref.length : void 0) > minHistLen) {
|
|
task.history = preenHistory(task.history);
|
|
}
|
|
return true;
|
|
});
|
|
_.defaults(user.history, {
|
|
todos: [],
|
|
exp: []
|
|
});
|
|
if (user.history.exp.length > minHistLen) {
|
|
user.history.exp = preenHistory(user.history.exp);
|
|
}
|
|
if (user.history.todos.length > minHistLen) {
|
|
return user.history.todos = preenHistory(user.history.todos);
|
|
}
|
|
};
|