|
|
|
@ -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|
|
|
|
|
|