|
|
|
@ -12,7 +12,7 @@ namespace :subjects do
|
|
|
|
|
"school_used_count, created_at, updated_at"
|
|
|
|
|
subjects.find_in_batches(batch_size: 50) do |s|
|
|
|
|
|
str = []
|
|
|
|
|
Parallel.each_with_index(s, in_processes: 6) do |subject, index|
|
|
|
|
|
Parallel.each_with_index(s, in_threads: 4) do |subject, index|
|
|
|
|
|
puts("---------------------data_statistic: #{subject.id}")
|
|
|
|
|
Rails.logger.info("---------------------data_statistic: #{subject.id}")
|
|
|
|
|
data = Subjects::DataStatisticService.new(subject)
|
|
|
|
@ -92,7 +92,6 @@ namespace :subjects do
|
|
|
|
|
Rails.logger.info("---------------------shixun_info_statistic: #{subject.id}")
|
|
|
|
|
data = Subjects::ShixunUsedInfoService.call(subject)
|
|
|
|
|
data.each do |key|
|
|
|
|
|
puts "###shixun_id: #{key[:shixun_id]}"
|
|
|
|
|
next if key[:shixun_id].nil?
|
|
|
|
|
str << ("(#{subject.id}, #{key[:shixun_id]}, '#{key[:stage]}', '#{key[:name]}', #{key[:challenge_count]}, " +
|
|
|
|
|
"#{key[:course_count]}, #{key[:school_count]}, #{key[:used_count]}, #{key[:passed_count]}, " +
|
|
|
|
@ -106,11 +105,11 @@ namespace :subjects do
|
|
|
|
|
str -= str_c
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if str.size > 0
|
|
|
|
|
sql = "REPLACE INTO subject_shixun_infos(#{column_value}) VALUES #{str.uniq.join(",")}"
|
|
|
|
|
puts sql
|
|
|
|
|
ActiveRecord::Base.connection.execute sql
|
|
|
|
|
if str.size > 0
|
|
|
|
|
sql = "REPLACE INTO subject_shixun_infos(#{column_value}) VALUES #{str.uniq.join(",")}"
|
|
|
|
|
puts sql
|
|
|
|
|
ActiveRecord::Base.connection.execute sql
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
puts("---------------------shixun_info_statistic_end")
|
|
|
|
|