4233: remove "delete log entries" option
authorPhil Hodgson <bitbucket@philhodgson.net>
Thu, 20 Nov 2014 14:55:35 +0000 (15:55 +0100)
committerPhil Hodgson <bitbucket@philhodgson.net>
Thu, 20 Nov 2014 14:55:35 +0000 (15:55 +0100)
  - this did not work as usefully as anticipated: one actually also wants the graph to be cleared, which has to be done manually anyway. The way to do this then would be to also invent a signal to be sent to the browser by the simulator, telling it to clear the graph stuff

services/api/lib/simulate_job_log.rb
services/api/lib/tasks/replay_job_log.rake

index 4ebca08d8a1925ede2b985069b9150e26ad52382..a0ab28d246aad26042a397bda3eedb56e9e7933a 100644 (file)
@@ -1,18 +1,14 @@
 module SimulateJobLog
-       # Note that deleting existing log entries only works if a simulated job uuid is also specified.
-       def replay(filename, multiplier = 1, delete_log_entries = false, simulated_job_uuid = nil)
+       def replay(filename, multiplier = 1, simulated_job_uuid = nil)
                raise "Environment must be development or test" unless [ 'test', 'development' ].include? ENV['RAILS_ENV']
 
            multiplier = multiplier.to_f
            multiplier = 1.0 if multiplier <= 0
 
-           delete_log_entries = (delete_log_entries.to_s.downcase == 'true')
-
            actual_start_time = Time.now
            log_start_time = nil
 
                act_as_system_user do
-                       Log.where("object_uuid = ?", simulated_job_uuid).delete_all if simulated_job_uuid && delete_log_entries
                        File.open(filename).each.with_index do |line, index|
                                cols = {}
                        cols[:timestamp], cols[:job_uuid], cols[:pid], cols[:task], cols[:event_type], cols[:message] = line.split(' ', 6)
index cfa19cdce1a4bf7eee43964e0003245004e0e44b..fad205b23d5a16e2b44018e213f37c91be53aa31 100644 (file)
@@ -1,7 +1,7 @@
 require 'simulate_job_log'
-desc 'Simulate job logging from a file. Four arguments: log filename, time multipler (optional), delete existing log entries (optional, default is false), simulated job uuid (optional). Note that deleting existing log entries only works if a simulated job uuid is also specified. E.g. (use quotation marks if using spaces between args): rake "replay_job_log[log.txt, 2.0, true, qr1hi-8i9sb-nf3qk0xzwwz3lre]"'
-task :replay_job_log, [:filename, :multiplier, :delete_log_entries, :uuid] => :environment do |t, args|
+desc 'Simulate job logging from a file. Three arguments: log filename, time multipler (optional), simulated job uuid (optional). E.g. (use quotation marks if using spaces between args): rake "replay_job_log[log.txt, 2.0, qr1hi-8i9sb-nf3qk0xzwwz3lre]"'
+task :replay_job_log, [:filename, :multiplier, :uuid] => :environment do |t, args|
        include SimulateJobLog
     abort("No filename specified.") if args[:filename].blank?
-    replay( args[:filename], args[:multiplier].to_f, args[:delete_log_entries], args[:uuid] )
+    replay( args[:filename], args[:multiplier].to_f, args[:uuid] )
 end