trabajo-afectivo/lib/sequencer/unit/import/zendesk/objects_total_count.rb

31 lines
765 B
Ruby
Raw Normal View History

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)
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!
)
end
end
end
end
end
end