diff --git a/script/index.coffee b/script/index.coffee index 37118b92ee..e8af72c0d9 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -485,7 +485,9 @@ api.wrap = (user, main=true) -> # ------ clearCompleted: (req, cb) -> - _.remove user.todos, (t)-> t.completed and !t.challenge?.id + user.todos = _.map user.todos, (t)-> + t.archived = true if t.completed and !t.challenge?.id + t user.markModified? 'todos' cb? null, user.todos @@ -1234,6 +1236,10 @@ api.wrap = (user, main=true) -> else task.value = task.value / 2 + user.todos.forEach (task) -> # Archive todos + if !task.archived && task.completed && moment(now).subtract('days',3).isAfter(moment(task.dateCompleted)) + task.archived = true + # Finished tallying ((user.history ?= {}).todos ?= []).push { date: now, value: todoTally }