fix(todos): add dateCompleted to todos so they're archived 3 days after completion, not 3 days after creation. fixes https://github.com/HabitRPG/habitrpg/issues/2478

This commit is contained in:
Tyler Renelle 2014-01-19 17:09:29 -08:00
parent 77b2e5400f
commit 587a660ac1
2 changed files with 4 additions and 2 deletions

View file

@ -11127,7 +11127,7 @@ var process=require("__browserify_process");(function() {
priority: 1,
challenge: {},
attribute: 'str',
created: new Date()
dateCreated: new Date()
};
_.defaults(task, defaults);
if (task.type === 'habit') {
@ -12137,6 +12137,7 @@ var process=require("__browserify_process");(function() {
if (options.cron) {
calculateDelta();
} else {
task.dateCompleted = direction === 'up' ? new Date : void 0;
calculateDelta();
addPoints();
multiplier = ((_ref3 = task.checklist) != null ? _ref3.length : void 0) || 1;

View file

@ -177,7 +177,7 @@ api.taskDefaults = (task={}) ->
priority: 1
challenge: {}
attribute: 'str'
created: new Date()
dateCreated: new Date()
_.defaults task, defaults
_.defaults(task, {up:true,down:true}) if task.type is 'habit'
_.defaults(task, {history: []}) if task.type in ['habit', 'daily']
@ -845,6 +845,7 @@ api.wrap = (user, main=true) ->
calculateDelta()
#don't touch stats on cron
else
task.dateCompleted = if direction is 'up' then new Date else undefined
calculateDelta()
addPoints() # obviously for delta>0, but also a trick to undo accidental checkboxes
# MP++ per checklist item in ToDo, bonus per CLI