多进程优化

video_transcode
daiao 5 years ago
parent 23a0868d1e
commit 4e32534698

@ -3,8 +3,9 @@ desc "统计每个学校使用数据"
namespace :static_all do
task :repo => :environment do
school_alls = School.includes(:courses, user_extensions: :user).all
proc_num = ENV['processes'].blank? ? 5 : ENV['processes'].to_i
school_alls.find_in_batches(batch_size: 50) do |schools|
Parallel.each(schools, in_processes: 5) do |school|
Parallel.each(schools, in_processes: proc_num) do |school|
puts("school_id: #{school.id}")
data = Schools::SchoolStatisticService.new(school)
sta_all = StaAll.find_or_initialize_by(school_id: school.id)

Loading…
Cancel
Save