|
|
|
@@ -0,0 +1,29 @@ |
|
|
|
|
|
|
|
desc "导入禅道数据" |
|
|
|
namespace :import_from_chandao do |
|
|
|
desc "bug数据" |
|
|
|
# 执行示例 bundle exec rake "import_from_chandao:bugs[企业内部工时管理系统-yystopf.csv, 1]" |
|
|
|
# RAILS_ENV=production bundle exec rake "import_from_chandao:bugs[企业内部工时管理系统-yystopf.csv, 1]" |
|
|
|
task :bugs, [:name, :pm_project_id] => :environment do |t, args| |
|
|
|
name = args.name |
|
|
|
CSV.foreach("#{Rails.root}/#{args.name}", headers: true) do | row | |
|
|
|
randd_field_hash = row.to_hash |
|
|
|
issue = Issue.new |
|
|
|
author = User.like(randd_field_hash['由谁创建']).take |
|
|
|
issue.author_id = author&.id |
|
|
|
assigner = User.like(randd_field_hash['指派给']).take |
|
|
|
issue.assigners << assigner |
|
|
|
issue.status_id = IssueStatus.first.id |
|
|
|
issue.tracker_id = Tracker.first.id |
|
|
|
issue.priority_id = randd_field_hash['优先级'].to_i |
|
|
|
issue.subject = randd_field_hash['Bug标题'] |
|
|
|
issue.description = randd_field_hash['重现步骤'] |
|
|
|
issue.created_on = randd_field_hash['创建日期'].to_time |
|
|
|
issue.due_date = randd_field_hash['截止日期'] |
|
|
|
issue.project_id = 0 |
|
|
|
issue.pm_project_id = args.pm_project_id |
|
|
|
issue.pm_issue_type = 3 |
|
|
|
issue.save! |
|
|
|
end |
|
|
|
end |
|
|
|
end |