|
|
|
@ -93,17 +93,16 @@ namespace :subjects do
|
|
|
|
|
data = Subjects::ShixunUsedInfoService.call(subject)
|
|
|
|
|
data.each do |key|
|
|
|
|
|
next if key[:shixun_id].nil?
|
|
|
|
|
str += ", " unless str.empty?
|
|
|
|
|
str += ("(#{subject.id}, #{key[:shixun_id]}, '#{key[:stage]}', '#{key[:name]}', #{key[:challenge_count]}, " +
|
|
|
|
|
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]}, " +
|
|
|
|
|
"#{key[:evaluate_count]}, #{key[:passed_ave_time]}, " +
|
|
|
|
|
"'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')")
|
|
|
|
|
if str.size == 1000
|
|
|
|
|
sql = "REPLACE INTO subject_shixun_infos(#{column_value}) VALUES #{str.uniq.join(",")}"
|
|
|
|
|
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
|
|
|
|
|