Commits

Yuya Nishihara committed ccad83e

added USER_EMAIL_MAP

Comments (0)

Files changed (1)

lib/tasks/import_kagemai_reports.rake

     STATUS_MAP = {'受付済' => '担当', '割当済み' => '担当', '修正済' => '解決', '確認待ち' => '解決',
                   '保留' => '新規', '完了' => '終了'}
     PRIORITY_MAP = {'緊急' => '急いで', '高' => '高め', '中' => '通常', '低' => '低め'}
+    USER_EMAIL_MAP = {}
 
     def self.initialize()
       # we cannot add LOAD_PATH before loading rails due to unexpected
           or raise "unknown priority: #{prio}"
     end
 
+    def self.map_author(report)  # report or message
+      name = encode(report['email'])
+      User.find_by_mail(USER_EMAIL_MAP[name] || name) or raise "unknown user: #{name}"
+    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 = Issue.new(:subject => reformat_subject(rep), :description => reformat_description(kagemai_proj_id, rep),
                             :created_on => rep.create_time)
           issue.project = redmine_proj
-          issue.author = User.find_by_mail(encode(rep.first['email'])) or raise "unknown user: #{encode(rep.first['email'])}"
+          issue.author = map_author(rep)
           issue.tracker = TRACKER_BUG  # FIXME
           issue.status = map_status(rep)
           issue.priority = map_priority(rep)
             next if msg == rep.first  # first message is treated as issue
             note = Journal.new(:notes => encode(msg['body']))
             note.journalized = issue
-            note.user = User.find_by_mail(encode(msg['email'])) or raise "unknown user: #{encode(rep['email'])}"
+            note.user = map_author(msg)
             # TODO: attachment
             Time.fake(msg.create_time) { note.save }
             print '.'