From ccdacb641f6644a687da747b86b24618de5f9b54 Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 15 Jan 2024 14:53:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E7=A6=85=E9=81=93=E9=9C=80=E6=B1=82=E6=95=B0=E6=8D=AE=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/import_issues_from_chandao.rake | 29 +++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/tasks/import_issues_from_chandao.rake b/lib/tasks/import_issues_from_chandao.rake index 1923f977a..15b038ce6 100644 --- a/lib/tasks/import_issues_from_chandao.rake +++ b/lib/tasks/import_issues_from_chandao.rake @@ -2,8 +2,8 @@ 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]" + # 执行示例 bundle exec rake "import_from_chandao:bugs[企业内部工时管理系统.csv, 3]" + # RAILS_ENV=production bundle exec rake "import_from_chandao:bugs[企业内部工时管理系统.csv, 3]" task :bugs, [:name, :pm_project_id] => :environment do |t, args| name = args.name CSV.foreach("#{Rails.root}/#{args.name}", headers: true) do | row | @@ -26,4 +26,29 @@ namespace :import_from_chandao do issue.save! end end + + # 执行示例 bundle exec rake "import_from_chandao:requirements[企业网站第二期.csv, 3]" + # RAILS_ENV=production bundle exec rake "import_from_chandao:requirements[企业网站第二期.csv, 3]" + task :requirements, [: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['需求名称'] + issue.description = randd_field_hash['需求描述'] + issue.created_on = randd_field_hash['创建日期'].to_time + issue.time_scale = randd_field_hash['预计工时'].to_i + issue.project_id = 0 + issue.pm_project_id = args.pm_project_id + issue.pm_issue_type = 1 + issue.save! + end + end end \ No newline at end of file