2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2017-08-14 11:56:23 +00:00
|
|
|
class Sequencer
|
|
|
|
class Unit
|
|
|
|
module Import
|
|
|
|
module Exchange
|
|
|
|
module FolderContacts
|
2018-01-08 15:30:09 +00:00
|
|
|
class Total < Sequencer::Unit::Base
|
2017-09-15 10:55:49 +00:00
|
|
|
include ::Sequencer::Unit::Exchange::Folders::Mixin::Folder
|
2018-01-08 15:30:09 +00:00
|
|
|
include ::Sequencer::Unit::Import::Common::Model::Statistics::Mixin::Common
|
2017-08-14 11:56:23 +00:00
|
|
|
|
|
|
|
uses :ews_folder_ids
|
|
|
|
provides :statistics_diff
|
|
|
|
|
|
|
|
def process
|
|
|
|
state.provide(:statistics_diff, diff)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def diff
|
2018-01-08 15:30:09 +00:00
|
|
|
result = empty_diff.merge(
|
|
|
|
folders: {},
|
|
|
|
)
|
2017-08-14 11:56:23 +00:00
|
|
|
|
2018-01-08 15:30:09 +00:00
|
|
|
folder_total_map.each do |display_path, total|
|
2017-08-14 11:56:23 +00:00
|
|
|
|
2018-01-08 15:30:09 +00:00
|
|
|
result[:folders][display_path] = empty_diff.merge(
|
|
|
|
total: total
|
|
|
|
)
|
|
|
|
|
|
|
|
result[:total] += total
|
2017-08-14 11:56:23 +00:00
|
|
|
end
|
|
|
|
result
|
|
|
|
end
|
|
|
|
|
2018-01-08 15:30:09 +00:00
|
|
|
def folder_total_map
|
2022-01-03 07:21:16 +00:00
|
|
|
ews_folder_ids.to_h do |folder_id|
|
2017-08-14 11:56:23 +00:00
|
|
|
folder = ews_folder.find(folder_id)
|
|
|
|
display_path = ews_folder.display_path(folder)
|
|
|
|
|
|
|
|
[display_path, folder.total_count]
|
2022-01-03 07:21:16 +00:00
|
|
|
end
|
2017-08-14 11:56:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|