From a02c622293ab58bff12a036f8ccfb3a118ad22f0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 6 Mar 2020 21:25:12 +0800 Subject: [PATCH] =?UTF-8?q?games=E8=A1=A8=E5=A2=9E=E5=8A=A0user=5Fid?= =?UTF-8?q?=E7=9A=84=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20200306131654_add_user_id_index_for_games.rb | 5 +++++ lib/tasks/static_all.rake | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20200306131654_add_user_id_index_for_games.rb diff --git a/db/migrate/20200306131654_add_user_id_index_for_games.rb b/db/migrate/20200306131654_add_user_id_index_for_games.rb new file mode 100644 index 000000000..ec92a1a08 --- /dev/null +++ b/db/migrate/20200306131654_add_user_id_index_for_games.rb @@ -0,0 +1,5 @@ +class AddUserIdIndexForGames < ActiveRecord::Migration[5.2] + def change + add_index :games, :user_id + end +end diff --git a/lib/tasks/static_all.rake b/lib/tasks/static_all.rake index 2290f0dc5..58a11572d 100644 --- a/lib/tasks/static_all.rake +++ b/lib/tasks/static_all.rake @@ -2,7 +2,7 @@ desc "统计每个学校使用数据" namespace :static_all do task :repo => :environment do - school_alls = School.includes(:courses, user_extensions: :user).all + school_alls = School.includes(courses: [:homework_commons, :attachments, :course_videos], user_extensions: :user).where(id: 117) proc_num = ENV['processes'].blank? ? 5 : ENV['processes'].to_i school_alls.find_in_batches(batch_size: 50) do |schools| Parallel.each(schools, in_processes: proc_num) do |school|