diff --git a/app/services/subjects/user_used_info_service.rb b/app/services/subjects/user_used_info_service.rb index 82fc5316b..c736b39b9 100644 --- a/app/services/subjects/user_used_info_service.rb +++ b/app/services/subjects/user_used_info_service.rb @@ -12,8 +12,8 @@ class Subjects::UserUsedInfoService < ApplicationService def call users_info = [] users = User.includes(myshixuns: :games).where(myshixuns: {shixun_id: shixun_ids}, games: {status: 2}, users: {is_test: false}) - users.find_in_batches do |u| - Parallel.each(u, in_processes: 5) do |user| + users.find_in_batches(batch_size: 500) do |u| + Parallel.each(u, in_processes: 10) do |user| myshixuns = user.myshixuns.select{|m| shixun_ids.include?(m.shixun_id)} name = "#{user.lastname}#{user.firstname}" passed_myshixun_count = myshixuns.select{|m| m.status == 1}.size diff --git a/lib/tasks/statistic_subject_info.rake b/lib/tasks/statistic_subject_info.rake index 253cac85a..bec200181 100644 --- a/lib/tasks/statistic_subject_info.rake +++ b/lib/tasks/statistic_subject_info.rake @@ -125,7 +125,7 @@ namespace :subjects do subjects.find_each(batch_size: 50) do |subject| puts("---------------------user_info_statistic: #{subject.id}") data = Subjects::UserUsedInfoService.call(subject) - Parallel.each(data, in_processes: 5) do |key| + Parallel.each(data, in_processes: 10) do |key| next if key[:user_id].nil? str += ", " unless str.empty? str += ("(#{key[:user_id]}, #{subject.id}, '#{key[:name].gsub(/'/, '"')}', #{key[:passed_myshixun_count]}, " +