|
|
|
@ -92,6 +92,7 @@ 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]}, " +
|
|
|
|
@ -99,10 +100,10 @@ namespace :subjects do
|
|
|
|
|
"'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')")
|
|
|
|
|
if str.size == 1000
|
|
|
|
|
str_c = str
|
|
|
|
|
str -= str_c
|
|
|
|
|
sql = "REPLACE INTO subject_shixun_infos(#{column_value}) VALUES #{str_c.uniq.join(",")}"
|
|
|
|
|
puts sql
|
|
|
|
|
ActiveRecord::Base.connection.execute sql
|
|
|
|
|
str -= str_c
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|