2014-08-19 17:03:26 +08:00
|
|
|
desc "User New Score description"
|
|
|
|
task :user_new_score do
|
|
|
|
puts "user_score sync."
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :user_new_score do
|
|
|
|
desc "calculating user score"
|
2014-08-21 14:56:44 +08:00
|
|
|
task :calculating => :environment do
|
2014-08-19 17:03:26 +08:00
|
|
|
include UserScoreHelper
|
|
|
|
User.all.each do |user|
|
2014-08-21 14:56:44 +08:00
|
|
|
result = user_scores(user,1).total_score
|
2014-08-19 17:03:26 +08:00
|
|
|
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|
|
2014-08-21 14:56:44 +08:00
|
|
|
result = user_scores(member.user,2,project).total_score
|
2014-08-19 17:03:26 +08:00
|
|
|
puts "#{user.login}/'s score in #{project.name} is #{result}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
puts "calculate completed"
|
|
|
|
end
|
|
|
|
end
|