feat(archive_todo): add cron to archive todos

This is part 2 of habitrpg#3062. Part 1 MUST be merged first.
Part 1 pull request: habitrpg#3302
This commit is contained in:
Jason Butz 2014-04-18 11:45:21 -04:00
parent c15789d6ae
commit 17aed0a9d7

View file

@ -1237,6 +1237,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 }