Fixes #3314 - Zendesk import fails if not supported field types are present.

This commit is contained in:
Thorsten Eckel 2020-11-30 17:34:04 +01:00
parent 9c8cfd83dd
commit 313081e677
9 changed files with 45 additions and 28 deletions

View file

@ -7,6 +7,7 @@ class Sequencer
def self.sequence
[
'Common::ModelClass::Organization',
'Import::Zendesk::ObjectAttribute::SanitizedType',
'Import::Zendesk::ObjectAttribute::SanitizedName',
'Import::Zendesk::ObjectAttribute::Add',
]

View file

@ -8,8 +8,9 @@ class Sequencer
[
'Common::ModelClass::Ticket',
'Import::Zendesk::TicketField::CheckCustom',
'Import::Zendesk::ObjectAttribute::SanitizedType',
'Import::Zendesk::TicketField::SanitizedName',
'Import::Zendesk::TicketField::Add',
'Import::Zendesk::ObjectAttribute::Add',
]
end
end

View file

@ -7,6 +7,7 @@ class Sequencer
def self.sequence
[
'Common::ModelClass::User',
'Import::Zendesk::ObjectAttribute::SanitizedType',
'Import::Zendesk::ObjectAttribute::SanitizedName',
'Import::Zendesk::ObjectAttribute::Add',
]

View file

@ -4,6 +4,9 @@ class Sequencer
module Common
module ObjectAttribute
class SanitizedName < Sequencer::Unit::Common::Provider::Named
prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
skip_action :skipped, :failed
private

View file

@ -4,8 +4,11 @@ class Sequencer
module Zendesk
module ObjectAttribute
class Add < Sequencer::Unit::Base
prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
uses :model_class, :sanitized_name, :resource
skip_action :skipped, :failed
uses :model_class, :sanitized_name, :resource, :backend_class
provides :instance
def process
@ -13,10 +16,6 @@ class Sequencer
backend_class.new(model_class, sanitized_name, resource)
end
end
def backend_class
"Import::Zendesk::ObjectAttribute::#{resource.type.capitalize}".constantize
end
end
end
end

View file

@ -0,0 +1,31 @@
class Sequencer
class Unit
module Import
module Zendesk
module ObjectAttribute
class SanitizedType < Sequencer::Unit::Base
include ::Sequencer::Unit::Import::Common::Model::Mixin::HandleFailure
prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
skip_action :skipped, :failed
uses :resource
provides :backend_class
private
def process
state.provide(:backend_class, backend_class)
rescue => e
handle_failure(e)
end
def backend_class
"Import::Zendesk::ObjectAttribute::#{resource.type.capitalize}".constantize
end
end
end
end
end
end
end

View file

@ -13,7 +13,8 @@ class Sequencer
custom_fields = resource.custom_fields
return {} if custom_fields.blank?
custom_fields.map do |custom_field|
custom_fields.select { |custom_field| ticket_field_map[ custom_field['id'] ].present? }
.map do |custom_field|
[
ticket_field_map[ custom_field['id'] ].to_sym, # remote_name
custom_field['value']

View file

@ -1,17 +0,0 @@
class Sequencer
class Unit
module Import
module Zendesk
module TicketField
class Add < Sequencer::Unit::Import::Zendesk::ObjectAttribute::Add
prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
skip_action :skipped
uses :action
end
end
end
end
end
end

View file

@ -4,11 +4,8 @@ class Sequencer
module Zendesk
module TicketField
class SanitizedName < Sequencer::Unit::Import::Common::ObjectAttribute::SanitizedName
prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
skip_action :skipped
uses :resource, :action
uses :resource
private