|
|
|
@@ -37,16 +37,18 @@ namespace :upgrade_issue_generate_data do |
|
|
|
puts "____________fix end____total:#{count}__________" |
|
|
|
end |
|
|
|
|
|
|
|
# 执行示例 bundle exec rake upgrade_issue_generate_data:move_assigned_to_id_to_assigners |
|
|
|
# 线上环境执行示例 RAILS_ENV=production bundle exec rake upgrade_issue_generate_data:move_assigned_to_id_to_assigners |
|
|
|
desc "upgrade_issue_generate_data: fix issue assigner to assigners" |
|
|
|
# 执行示例 bundle exec rake upgrade_issue_generate_data:build_assigners_and_participants |
|
|
|
# 线上环境执行示例 RAILS_ENV=production bundle exec rake upgrade_issue_generate_data:build_assigners_and_participants |
|
|
|
desc "upgrade_issue_generate_data: fix issue assigners and participants" |
|
|
|
|
|
|
|
task move_assigned_to_id_to_assigners: :environment do |
|
|
|
task build_assigners_and_participants: :environment do |
|
|
|
puts "____________fix start________________" |
|
|
|
count = 0 |
|
|
|
Issue.where.not(assigned_to_id: nil).find_each do |issue| |
|
|
|
Issue.order(created_on: :desc)find_each do |issue| |
|
|
|
count += 1 |
|
|
|
issue.assigners = User.where(id: issue.assigned_to_id) |
|
|
|
issue.issue_assigners.find_or_create_by(assigner_id: issue.assigned_to_id) |
|
|
|
issue.issue_participants.find_or_create_by(participant_id: issue.assigned_to_id, participant_type: 'assigned') |
|
|
|
issue.issue_participants.find_or_create_by(participant_id: issue.author_id, participant_type: 'authored') |
|
|
|
end |
|
|
|
puts "____________fix end____total:#{count}__________" |
|
|
|
end |