From 17aed0a9d7cf74327ef004af23ef579036522446 Mon Sep 17 00:00:00 2001 From: Jason Butz Date: Fri, 18 Apr 2014 11:45:21 -0400 Subject: [PATCH 1/2] 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 --- script/index.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script/index.coffee b/script/index.coffee index a6ada7d430..7a6d66b5da 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -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 } From 52ff5a7d5a3eb414c4884ede106de35edcb7d504 Mon Sep 17 00:00:00 2001 From: Jason Butz Date: Fri, 18 Apr 2014 12:33:45 -0400 Subject: [PATCH 2/2] feat(archive_todo): update to archive todos I thought this bit of code was in the other repo. So long as part 3 follows close behind this, there shouldn't be an issue --- script/index.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/index.coffee b/script/index.coffee index 7a6d66b5da..f410d4d51c 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