mapping.rb 811 B

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Freshdesk::TimeEntry::Mapping < Sequencer::Unit::Base
  3. include ::Sequencer::Unit::Import::Common::Mapping::Mixin::ProvideMapped
  4. uses :resource, :id_map
  5. def process
  6. provide_mapped do
  7. {
  8. time_unit: time_unit,
  9. ticket_id: ticket_id,
  10. created_by_id: agent_id,
  11. created_at: resource['created_at'],
  12. updated_at: resource['updated_at'],
  13. }
  14. end
  15. end
  16. private
  17. def time_unit
  18. hours, minutes = resource['time_spent'].match(%r{(\d{2}):(\d{2})}).captures
  19. (hours.to_i * 60) + minutes.to_i
  20. end
  21. def ticket_id
  22. id_map['Ticket'][resource['ticket_id']]
  23. end
  24. def agent_id
  25. id_map['User'][resource['agent_id']]
  26. end
  27. end