total.rb 917 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Exchange::FolderContacts::Total < Sequencer::Unit::Base
  3. include ::Sequencer::Unit::Exchange::Folders::Mixin::Folder
  4. include ::Sequencer::Unit::Import::Common::Model::Statistics::Mixin::Common
  5. uses :ews_folder_ids
  6. provides :statistics_diff
  7. def process
  8. state.provide(:statistics_diff, diff)
  9. end
  10. private
  11. def diff
  12. result = empty_diff.merge(
  13. folders: {},
  14. )
  15. folder_total_map.each do |display_path, total|
  16. result[:folders][display_path] = empty_diff.merge(
  17. total: total
  18. )
  19. result[:total] += total
  20. end
  21. result
  22. end
  23. def folder_total_map
  24. ews_folder_ids.to_h do |folder_id|
  25. folder = ews_folder.find(folder_id)
  26. display_path = ews_folder.display_path(folder)
  27. [display_path, folder.total_count]
  28. end
  29. end
  30. end