|
|
|
@ -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)
|
|
|
|
|