|
|
@ -48,7 +48,7 @@ namespace :subjects do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
subjects.find_in_batches(batch_size: 50) do |s|
|
|
|
|
subjects.find_in_batches(batch_size: 50) do |s|
|
|
|
|
str = []
|
|
|
|
str = []
|
|
|
|
Parallel.each(s, in_processes: 4) do |subject|
|
|
|
|
Parallel.each(s, in_threads: 4) do |subject|
|
|
|
|
puts("---------------------course_info_statistic: #{subject.id}")
|
|
|
|
puts("---------------------course_info_statistic: #{subject.id}")
|
|
|
|
Rails.logger.info("---------------------course_info_statistic: #{subject.id}")
|
|
|
|
Rails.logger.info("---------------------course_info_statistic: #{subject.id}")
|
|
|
|
data = Subjects::CourseUsedInfoService.call(subject)
|
|
|
|
data = Subjects::CourseUsedInfoService.call(subject)
|
|
|
@ -57,6 +57,7 @@ namespace :subjects do
|
|
|
|
str << ("(#{subject.id}, #{key[:school_id]}, '#{key[:school_name]}', #{key[:course_count]}, " +
|
|
|
|
str << ("(#{subject.id}, #{key[:school_id]}, '#{key[:school_name]}', #{key[:course_count]}, " +
|
|
|
|
"#{key[:student_count]}, #{key[:choice_shixun_num]}, #{key[:choice_shixun_frequency]}, " +
|
|
|
|
"#{key[:student_count]}, #{key[:choice_shixun_num]}, #{key[:choice_shixun_frequency]}, " +
|
|
|
|
"'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')")
|
|
|
|
"'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')")
|
|
|
|
|
|
|
|
puts "str: #{str}"
|
|
|
|
if str.size == 1000
|
|
|
|
if str.size == 1000
|
|
|
|
sql = "REPLACE INTO subject_course_records(#{column_value}) VALUES #{str.uniq.join(",")}"
|
|
|
|
sql = "REPLACE INTO subject_course_records(#{column_value}) VALUES #{str.uniq.join(",")}"
|
|
|
|
str_c = str
|
|
|
|
str_c = str
|
|
|
|