aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2014-07-30 03:01:36 +0200
committerHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2014-07-30 03:18:50 +0200
commit8d7b012a535b18925b37d0d00d9c33e7183c36e9 (patch)
treecb661bb610bc7fa75a2bd8062ee3a4f653cd9bed /lib
parent5235cc3e6fa882ba2c8bb886276981d898a7c0bd (diff)
downloadecs2-8d7b012a535b18925b37d0d00d9c33e7183c36e9.tar.gz
ecs2-8d7b012a535b18925b37d0d00d9c33e7183c36e9.zip
Moved gc of anonymous participants to rake task.
Don't forget to garbage collect anonymous participants in a cronjob.
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/ecs_garbage_collect_anonymous_participants.rake10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/tasks/ecs_garbage_collect_anonymous_participants.rake b/lib/tasks/ecs_garbage_collect_anonymous_participants.rake
new file mode 100644
index 0000000..f0c4836
--- /dev/null
+++ b/lib/tasks/ecs_garbage_collect_anonymous_participants.rake
@@ -0,0 +1,10 @@
+namespace :ecs do
+ desc "Delete outtimed anonymous participants."
+ task :gc_anonymous_participants => :environment do
+ num= Participant.find(:all, :conditions => ["(anonymous = ?) AND (ttl < ?)", true, DateTime.now.utc]).length
+ Participant.destroy_all(["(anonymous = ?) AND (ttl < ?)", true, DateTime.now.utc])
+ txt= "Number of deleted messages: #{num}"
+ puts txt
+ RAILS_DEFAULT_LOGGER.info txt
+ end
+end