diff --git a/lib/tasks/daily_update_star_for_shixun.rake b/lib/tasks/daily_update_star_for_shixun.rake index aebac0d7..f002395d 100644 --- a/lib/tasks/daily_update_star_for_shixun.rake +++ b/lib/tasks/daily_update_star_for_shixun.rake @@ -3,8 +3,9 @@ namespace :daily_update_star_for_shixun do desc "update star count every day for shixun " task :execute => :environment do - shixuns = Shixun.select(:id, :averge_star) - + shixuns = Shixun.select("id, averge_star") + shixuns = shixuns.where(id: ENV['shixun_id']) if ENV['shixun_id'].present? + shixuns.find_in_batches(batch_size: 10000) do |group| update_sql = "UPDATE shixuns SET averge_star = CASE id " Parallel.each(group, in_threads: 6) do |shixun| diff --git a/lib/tasks/update_myshixuns_count_for_shixun.rake b/lib/tasks/update_myshixuns_count_for_shixun.rake index ce8f530e..fe4f3ef3 100644 --- a/lib/tasks/update_myshixuns_count_for_shixun.rake +++ b/lib/tasks/update_myshixuns_count_for_shixun.rake @@ -3,8 +3,8 @@ namespace :update_myshixuns_count_for_shixun do desc "update myshixuns count for shixun every day" task :execute => :environment do - shixuns = Shixun.joins(:myshixuns).select("shixuns.id, COUNT(myshixuns.id) AS query_myshixuns_count") - .group("shixuns.id") + shixuns = Shixun.joins(:myshixuns).select("shixuns.id, COUNT(myshixuns.id) AS query_myshixuns_count").group("shixuns.id") + shixuns = shixuns.where(id: ENV['shixun_id']) if ENV['shixun_id'].present? shixuns.find_in_batches(batch_size: 10000) do |group| update_sql = "UPDATE shixuns SET myshixuns_count = CASE id "