diff options
author | micha <micha@tpad.(none)> | 2012-01-16 18:49:59 +0100 |
---|---|---|
committer | micha <micha@tpad.(none)> | 2012-01-16 18:49:59 +0100 |
commit | b630f48c8c274c698836cf2af8dff5b153b986ac (patch) | |
tree | 542a17fdf4da1136ee3e287de350a9cbee6f7e14 | |
parent | d9c693f95e10dd15ddf100d62eb862188d3f63b5 (diff) |
Cleanup tasks
-rw-r--r-- | application.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/application.rb b/application.rb index 1c0303e..76c2b8c 100644 --- a/application.rb +++ b/application.rb @@ -179,6 +179,16 @@ post '/?' do task.uri + "\n" end +# Clean tasks. Delete every completed task older than 30 days +delete '/cleanup' do + tasklist = Task.all + tasklist.each do |task| + if task.metadata[OT.hasStatus] == 'Completed' + task.delete if Time.now - Time.parse(task.created_at) > 2592000 + end + end +end + # Change task status. Possible URIs are: ` # - /task/Cancelled # - /task/Completed: requires taskURI argument |