You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
736 B
20 lines
736 B
desc "同步学院或者单位评测数"
|
|
|
|
namespace :sync_evaluate do
|
|
task outpus_count: :environment do
|
|
School.find_in_batches(batch_size: 50) do |school|
|
|
Parallel.each_with_index(school, in_processes: 5) do |s|
|
|
puts "school_id:#{s.id}"
|
|
evaluate_count = Game.find_by_sql("select sum(g.evaluate_count) as e_count from games g, user_extensions ue where
|
|
g.user_id = ue.user_id and ue.school_id = '#{s.id}'").first.try(:e_count)
|
|
|
|
puts "evaluate_count: #{evaluate_count}"
|
|
report = SchoolReport.find_or_initialize_by(school_id: s.id)
|
|
report.school_name = s.name
|
|
report.shixun_evaluate_count = evaluate_count
|
|
|
|
report.save
|
|
end
|
|
end
|
|
end
|
|
end |