desc "User New Score description" task :user_new_score do puts "user_score sync." end #速度太慢,不用 namespace :user_new_score do desc "calculating user score" task :calculating => :environment do include UserScoreHelper User.all.each do |user| result = user_scores(user,1).total_score puts "score of #{user.login} is #{result}" end Project.where("project_type != 1").all.each do |project| project.member_principals.includes(:roles, :principal).all.each do |member| result = user_scores(member.user,2,project).total_score puts "#{user.login}/'s score in #{project.name} is #{result}" end end puts "calculate completed" end end