2018-01-08 15:29:34 +00:00
|
|
|
class Sequencer
|
|
|
|
class Unit
|
|
|
|
module Import
|
|
|
|
module Zendesk
|
|
|
|
class ObjectsTotalCount < Sequencer::Unit::Common::Provider::Attribute
|
|
|
|
include ::Sequencer::Unit::Import::Common::Model::Statistics::Mixin::EmptyDiff
|
|
|
|
|
|
|
|
uses :client
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def statistics_diff
|
|
|
|
%i[Groups Users Organizations Tickets].each_with_object({}) do |object, stats|
|
2020-04-08 06:23:58 +00:00
|
|
|
stats[object] = object_diff(object)
|
2018-01-08 15:29:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-08 06:23:58 +00:00
|
|
|
def object_diff(object)
|
|
|
|
collection_name = object.to_s.underscore
|
|
|
|
collection = client.send collection_name
|
|
|
|
|
|
|
|
empty_diff.merge(
|
|
|
|
total: collection.count!
|
|
|
|
)
|
2018-01-08 15:29:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|