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|