diff --git a/app/models/attempt.rb b/app/models/attempt.rb index 85b14dee..3d9fc4f4 100644 --- a/app/models/attempt.rb +++ b/app/models/attempt.rb @@ -77,6 +77,7 @@ class Attempt < ApplicationRecord end def update_counts + return if ENV['BULK_PROCESS'] recipient.update_attributes( attempts_count: recipient.attempts.count, responses_count: recipient.attempts.with_answer.count diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index 1eeacd73..849ef9fa 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -145,7 +145,7 @@ namespace :data do bad_answers = {} year = '2017' - timeToRun = 10000 * 60 * 60 + timeToRun = 6 * 60 * 60 startIndex = 0 startTime = Time.new @@ -158,12 +158,12 @@ namespace :data do t = Time.new csv.each_with_index do |row, index| - # next if index < startIndex - # - # if Time.new - startTime >= timeToRun - # puts("ENDING #{timeToRun} SECONDS: #{Time.new - startTime} = #{startIndex} -> #{index} = #{index - startIndex} or #{(Time.new - t) / (index - startIndex)} per second") - # break - # end + next if index < startIndex + + if Time.new - startTime >= timeToRun + puts("ENDING #{timeToRun} SECONDS: #{Time.new - startTime} = #{startIndex} -> #{index} = #{index - startIndex} or #{(Time.new - t) / (index - startIndex)} per second") + break + end if index % 10 == 0 puts("DATAMSG: PROCESSING ROW: #{index} OUT OF #{csv.length} ROWS: #{Time.new - t} - Total: #{Time.new - startTime} - #{timeToRun - (Time.new - startTime)} TO GO")