socialforge/lib/tasks/user_new_score.rake

23 lines
686 B
Ruby
Raw Normal View History

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"
task :calculating => :environment do
2014-08-19 17:03:26 +08:00
include UserScoreHelper
User.all.each do |user|
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|
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