From 95e0d2d368edbba775aa15165c8dd907b094c924 Mon Sep 17 00:00:00 2001 From: jasder duan Date: Thu, 30 Nov 2023 14:49:21 +0800 Subject: [PATCH] =?UTF-8?q?ADD=20=E6=B7=BB=E5=8A=A0=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=9E=E8=B7=B5=E9=A1=B9=E7=9B=AE=E7=9A=84?= =?UTF-8?q?myshixun=5Fcount=20=E5=92=8Caverge=5Fstar=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/daily_update_star_for_shixun.rake | 5 +++-- lib/tasks/update_myshixuns_count_for_shixun.rake | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) 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 "