diff options
author | Heiko Bernloehr <freeit@nflexpvipecs.rus.uni-stuttgart.de> | 2016-02-12 05:26:11 +0100 |
---|---|---|
committer | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2016-02-12 06:20:00 +0100 |
commit | d19e0a87c27895bf7f910171b22d7b75afd6835e (patch) | |
tree | 2cd713ed58dfe0a56164c01a4b1c8b8a38567fc9 | |
parent | 3b3df7d268d4973e4cb5407155a1ea3b2b50ebc8 (diff) | |
download | ecs2-d19e0a87c27895bf7f910171b22d7b75afd6835e.tar.gz ecs2-d19e0a87c27895bf7f910171b22d7b75afd6835e.zip |
New rake vip:gc_results task.
-rw-r--r-- | lib/tasks/vip_garbage_collect_solutions.rake | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/tasks/vip_garbage_collect_solutions.rake b/lib/tasks/vip_garbage_collect_solutions.rake new file mode 100644 index 0000000..3c99fbf --- /dev/null +++ b/lib/tasks/vip_garbage_collect_solutions.rake @@ -0,0 +1,20 @@ +namespace :vip do + desc "Delete old solutions." + task :gc_solutions => :environment do + ttl= 15.hours.ago + i=0 + Message.for_resource("numlab", "solutions").for_not_removed.each do |msg| + if msg.created_at < ttl + m = Message.find(msg.id) + m.destroy_as_sender + i+=1 + txt= "gc_solutions: #{msg.ressource.namespace}/#{msg.ressource.ressource}/#{msg.id.to_s}" + RAILS_DEFAULT_LOGGER.info txt + #puts txt + end + end + txt= "gc_solutions: Deleted #{i} solutions." + RAILS_DEFAULT_LOGGER.info txt + puts txt + end +end |