diff.rb 853 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Ldap::User::Statistics::Diff < Sequencer::Unit::Base
  3. include ::Sequencer::Unit::Import::Common::Model::Statistics::Mixin::ActionDiff
  4. uses :instance, :associations, :signup_role_ids
  5. def process
  6. state.provide(:statistics_diff) do
  7. add_role_ids(diff)
  8. end
  9. end
  10. private
  11. def add_role_ids(statistics)
  12. return statistics if instance.blank?
  13. return statistics if associations.blank?
  14. # add the parent role_ids hash
  15. # so we can fill it
  16. statistics[:role_ids] = {}
  17. associations[:role_ids] ||= signup_role_ids
  18. # add the diff for each role_id the user is assigned to
  19. associations[:role_ids].each_with_object(statistics) do |role_id, result|
  20. result[:role_ids][role_id] = diff
  21. end
  22. end
  23. end