Fixes #3314 - Zendesk import fails if not supported field types are present.
This commit is contained in:
parent
9c8cfd83dd
commit
313081e677
9 changed files with 45 additions and 28 deletions
|
@ -7,6 +7,7 @@ class Sequencer
|
||||||
def self.sequence
|
def self.sequence
|
||||||
[
|
[
|
||||||
'Common::ModelClass::Organization',
|
'Common::ModelClass::Organization',
|
||||||
|
'Import::Zendesk::ObjectAttribute::SanitizedType',
|
||||||
'Import::Zendesk::ObjectAttribute::SanitizedName',
|
'Import::Zendesk::ObjectAttribute::SanitizedName',
|
||||||
'Import::Zendesk::ObjectAttribute::Add',
|
'Import::Zendesk::ObjectAttribute::Add',
|
||||||
]
|
]
|
||||||
|
|
|
@ -8,8 +8,9 @@ class Sequencer
|
||||||
[
|
[
|
||||||
'Common::ModelClass::Ticket',
|
'Common::ModelClass::Ticket',
|
||||||
'Import::Zendesk::TicketField::CheckCustom',
|
'Import::Zendesk::TicketField::CheckCustom',
|
||||||
|
'Import::Zendesk::ObjectAttribute::SanitizedType',
|
||||||
'Import::Zendesk::TicketField::SanitizedName',
|
'Import::Zendesk::TicketField::SanitizedName',
|
||||||
'Import::Zendesk::TicketField::Add',
|
'Import::Zendesk::ObjectAttribute::Add',
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,7 @@ class Sequencer
|
||||||
def self.sequence
|
def self.sequence
|
||||||
[
|
[
|
||||||
'Common::ModelClass::User',
|
'Common::ModelClass::User',
|
||||||
|
'Import::Zendesk::ObjectAttribute::SanitizedType',
|
||||||
'Import::Zendesk::ObjectAttribute::SanitizedName',
|
'Import::Zendesk::ObjectAttribute::SanitizedName',
|
||||||
'Import::Zendesk::ObjectAttribute::Add',
|
'Import::Zendesk::ObjectAttribute::Add',
|
||||||
]
|
]
|
||||||
|
|
|
@ -4,6 +4,9 @@ class Sequencer
|
||||||
module Common
|
module Common
|
||||||
module ObjectAttribute
|
module ObjectAttribute
|
||||||
class SanitizedName < Sequencer::Unit::Common::Provider::Named
|
class SanitizedName < Sequencer::Unit::Common::Provider::Named
|
||||||
|
prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
|
||||||
|
|
||||||
|
skip_action :skipped, :failed
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,11 @@ class Sequencer
|
||||||
module Zendesk
|
module Zendesk
|
||||||
module ObjectAttribute
|
module ObjectAttribute
|
||||||
class Add < Sequencer::Unit::Base
|
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
|
provides :instance
|
||||||
|
|
||||||
def process
|
def process
|
||||||
|
@ -13,10 +16,6 @@ class Sequencer
|
||||||
backend_class.new(model_class, sanitized_name, resource)
|
backend_class.new(model_class, sanitized_name, resource)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def backend_class
|
|
||||||
"Import::Zendesk::ObjectAttribute::#{resource.type.capitalize}".constantize
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
|
@ -13,7 +13,8 @@ class Sequencer
|
||||||
custom_fields = resource.custom_fields
|
custom_fields = resource.custom_fields
|
||||||
return {} if custom_fields.blank?
|
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
|
ticket_field_map[ custom_field['id'] ].to_sym, # remote_name
|
||||||
custom_field['value']
|
custom_field['value']
|
||||||
|
|
|
@ -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
|
|
|
@ -4,11 +4,8 @@ class Sequencer
|
||||||
module Zendesk
|
module Zendesk
|
||||||
module TicketField
|
module TicketField
|
||||||
class SanitizedName < Sequencer::Unit::Import::Common::ObjectAttribute::SanitizedName
|
class SanitizedName < Sequencer::Unit::Import::Common::ObjectAttribute::SanitizedName
|
||||||
prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
|
|
||||||
|
|
||||||
skip_action :skipped
|
uses :resource
|
||||||
|
|
||||||
uses :resource, :action
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue