aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Bernloehr <freeit@nflexpvipecs.rus.uni-stuttgart.de>2016-02-12 05:26:55 +0100
committerHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2016-02-12 06:20:00 +0100
commitfc7c4a15f0480d69a7966f6b62c276ffe3ef9506 (patch)
treea1c7271de3f74a70066fe52f6d344dc136b1e241
parentd19e0a87c27895bf7f910171b22d7b75afd6835e (diff)
downloadecs2-fc7c4a15f0480d69a7966f6b62c276ffe3ef9506.tar.gz
ecs2-fc7c4a15f0480d69a7966f6b62c276ffe3ef9506.zip
New rake vip:gc_evaluations task.
-rw-r--r--lib/tasks/vip_garbage_collect_evaluations.rake22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/tasks/vip_garbage_collect_evaluations.rake b/lib/tasks/vip_garbage_collect_evaluations.rake
new file mode 100644
index 0000000..c9d963a
--- /dev/null
+++ b/lib/tasks/vip_garbage_collect_evaluations.rake
@@ -0,0 +1,22 @@
+namespace :vip do
+ desc "Delete old evaluations."
+ task :gc_evaluations => :environment do
+ ttl= 15.hours.ago
+ i=0
+ Message.for_resource("numlab", "evaluations").for_not_removed.each do |msg|
+ begin
+ if msg.created_at < ttl
+ m = Message.find(msg.id)
+ m.destroy_as_sender
+ i+=1
+ txt= "gc_evaluations: #{msg.ressource.namespace}/#{msg.ressource.ressource}/#{msg.id.to_s}"
+ RAILS_DEFAULT_LOGGER.info txt
+ puts txt
+ end
+ end
+ end
+ txt= "gc_evaluations: Deleted #{i} evaluations."
+ RAILS_DEFAULT_LOGGER.info txt
+ puts txt
+ end
+end