From b4eb49ab57f2167914db24b56213490167964b6d Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 10 Apr 2015 21:22:04 +0200 Subject: [PATCH] OTRS 3.1 approved. --- lib/import/otrs2.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/import/otrs2.rb b/lib/import/otrs2.rb index e43c5f4f5..24cd92f98 100644 --- a/lib/import/otrs2.rb +++ b/lib/import/otrs2.rb @@ -510,6 +510,9 @@ module Import::OTRS2 result.each {|record| + # cleanup values + _cleanup(record) + ticket_new = { :title => '', :created_by_id => 1, @@ -680,7 +683,7 @@ module Import::OTRS2 #puts "HS: #{record['History'].inspect}" record['History'].each { |history| if history['HistoryType'] == 'NewTicket' - puts "HS.add( #{history.inspect} )" + #puts "HS.add( #{history.inspect} )" res = History.add( :id => history['HistoryID'], :o_id => history['TicketID'], @@ -689,7 +692,7 @@ module Import::OTRS2 :created_at => history['CreateTime'], :created_by_id => history['CreateBy'] ) - puts "res #{res.inspect}" + #puts "res #{res.inspect}" end if history['HistoryType'] == 'StateUpdate' data = history['Name'] @@ -1243,4 +1246,19 @@ module Import::OTRS2 record['ValidID'] = true end end + + # cleanup invalid values + + def self._cleanup(record) + record.each {|key, value| + if value == '0000-00-00 00:00:00' + record[key] = nil + end + } + + # fix OTRS 3.1 bug, no close time if ticket is created + if record['StateType'] == 'closed' && ( !record['Closed'] || record['Closed'].empty? ) + record['Closed'] = record['Created'] + end + end end \ No newline at end of file