diff --git a/lib/tasks/statistic_subject_info.rake b/lib/tasks/statistic_subject_info.rake index 5f5adf1d4..341b5eaf9 100644 --- a/lib/tasks/statistic_subject_info.rake +++ b/lib/tasks/statistic_subject_info.rake @@ -38,9 +38,7 @@ namespace :subjects do end subjects.find_in_batches(batch_size: 50) do |s| - Parallel.in_processes(4) do |i| - - end + str = [] Parallel.each_with_index(s, in_processes: 4) do |subject, index| puts("---------------------data_statistic: #{subject.id}") Rails.logger.info("---------------------data_statistic: #{subject.id}") @@ -54,11 +52,10 @@ namespace :subjects do "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") puts "index: #{index}; worker_number: #{Parallel.worker_number}" puts "####str: #{str}" - if str.size == 100 || subject == s.last + if subject == s.last sql = "REPLACE INTO subject_records(#{column_value}) VALUES #{str.uniq.join(",")}" puts sql ActiveRecord::Base.connection.execute sql - str = [] end end end