mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 12:02:13 +00:00
Merge pull request #198 from jbutz/todo_archive_flag_cron
feat(archive_todo): add cron to archive todos
This commit is contained in:
commit
00147a8671
1 changed files with 7 additions and 1 deletions
|
|
@ -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 }
|
||||
|
|
|
|||
Loading…
Reference in a new issue