Commits

Yuya Nishihara committed 9f7c05b

added PRIORITY_MAP support

  • Participants
  • Parent commits 4624c8f

Comments (0)

Files changed (1)

File lib/tasks/import_kagemai_reports.rake

     # Kagemai to Redmine
     STATUS_MAP = {'受付済' => '担当', '割当済み' => '担当', '修正済' => '解決', '確認待ち' => '解決',
                   '保留' => '新規', '完了' => '終了'}
+    PRIORITY_MAP = {'緊急' => '急いで', '高' => '高め', '中' => '通常', '低' => '低め'}
 
     def self.initialize()
       # we cannot add LOAD_PATH before loading rails due to unexpected
       IssueStatus.find_by_name(STATUS_MAP[status] || status) or raise "unknown status: #{status}"
     end
 
+    def self.map_priority(report)
+      return Enumeration.default('IPRI') unless report.first.has_element? 'priority'
+      prio = encode(report['priority'])
+      Enumeration.find(:first, :conditions => ['opt = ? AND name = ?', 'IPRI', PRIORITY_MAP[prio] || prio]) \
+          or raise "unknown priority: #{prio}"
+    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.author = User.find_by_mail(encode(rep.first['email'])) or raise "unknown user: #{encode(rep.first['email'])}"
           issue.tracker = TRACKER_BUG  # FIXME
           issue.status = map_status(rep)
-          # TODO: priority, attachment
+          issue.priority = map_priority(rep)
+          # TODO: attachment
 
           Time.fake(rep.modify_time) { issue.save }
           print "[#{rep.id}->#{issue.id}]"