diff options
Diffstat (limited to 'lib/tasks/ecs_garbage_collect_anonymous_participants.rake')
-rw-r--r-- | lib/tasks/ecs_garbage_collect_anonymous_participants.rake | 10 |
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 |