Commits

Yuya Nishihara committed 4e04a5d

implemented status mapper

  • Participants
  • Parent commits 58d02e4

Comments (0)

Files changed (1)

File lib/tasks/import_kagemai_reports.rake

     TRACKER_FEATURE = Tracker.find_by_position(2)
     TRACKER_SUPPORT = Tracker.find_by_position(3)
 
+    # Kagemai to Redmine
+    STATUS_MAP = {'受付済' => '担当', '修正済' => '解決', '保留' => '新規', '完了' => '終了'}
+
     def self.initialize()
       # we cannot add LOAD_PATH before loading rails due to unexpected
       # `uninitialized constant XMLScan::Visitor' error.
       "[Kagemai:#{'%03d' % report.id}] #{encode(report.attr('title'))}"
     end
 
+    def self.map_status(report)
+      status = encode(report['status'])
+      IssueStatus.find_by_name(STATUS_MAP[status] || status) or raise "unknown status: #{status}"
+    end
+
     def self.import_project(redmine_proj_id, kagemai_proj_id)
       raise 'redmine_project not specified' unless redmine_proj_id
       raise 'kagemai_project not specified' unless kagemai_proj_id
         issue.project = redmine_proj
         issue.author = User.find_by_mail(encode(rep.first['email'])) or raise "unknown user: #{encode(rep.first['email'])}"
         issue.tracker = TRACKER_BUG  # FIXME
-        # TODO: priority, status, attachment
+        issue.status = map_status(rep)
+        # TODO: priority, attachment
 
         Time.fake(rep.modify_time) { issue.save }
         print "[#{rep.id}->#{issue.id}]"