From f76349219d6557aae0e8052d01ddf8116fd97a70 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 13 Feb 2020 18:43:10 +0800 Subject: [PATCH] 1 --- lib/tasks/statistic_subject_info.rake | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/tasks/statistic_subject_info.rake b/lib/tasks/statistic_subject_info.rake index 3d0f0109c..61a8201a6 100644 --- a/lib/tasks/statistic_subject_info.rake +++ b/lib/tasks/statistic_subject_info.rake @@ -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