aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Bernloehr <freeit@nflexpvipecs.rus.uni-stuttgart.de>2016-02-12 05:28:21 +0100
committerHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2016-02-12 06:20:00 +0100
commit2042748f2c65b346f5fe5408e4cd990081a7380e (patch)
tree2d9a26771fa74bdb39ac5869ea4fbd1ca9c48f94
parentfc7c4a15f0480d69a7966f6b62c276ffe3ef9506 (diff)
downloadecs2-2042748f2c65b346f5fe5408e4cd990081a7380e.tar.gz
ecs2-2042748f2c65b346f5fe5408e4cd990081a7380e.zip
New rake vip:count_no_ttl_exercises task.
-rw-r--r--lib/tasks/vip_count_exercises_without_ttl.rake25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/tasks/vip_count_exercises_without_ttl.rake b/lib/tasks/vip_count_exercises_without_ttl.rake
new file mode 100644
index 0000000..0adfc14
--- /dev/null
+++ b/lib/tasks/vip_count_exercises_without_ttl.rake
@@ -0,0 +1,25 @@
+namespace :vip do
+ desc "Count exercises without TTL attribute."
+ task :count_no_ttl_exercises => :environment do
+ # ttl= 20*60 # 20 minutes
+ ttl= 30*24*3600 # 9999 years
+ nottl=0
+ noexercise=0
+ Message.for_resource("numlab", "exercises").sort{|x,y| x.created_at <=> y.created_at}.each do |msg|
+ begin
+ if JSON.parse(msg.body)['Exercise'].nil?
+ noexercise+= 1
+ elsif JSON.parse(msg.body)['Exercise']['TTL'].nil?
+ nottl+= 1
+ end
+ rescue JSON::ParserError, Exception
+ txt= "Filter Exception: "+$!.class.to_s+": #{msg.ressource.namespace}/#{msg.ressource.ressource}/#{msg.id.to_s}"
+ RAILS_DEFAULT_LOGGER.error txt
+ puts txt
+ end
+ end
+ puts "Number of exercises: #{Message.for_resource("numlab", "exercises").length-noexercise}"
+ puts "nottl: "+nottl.to_s
+ puts "noexercise: "+noexercise.to_s
+ end
+end