tickets.rb 989 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Freshdesk::Tickets < Sequencer::Unit::Import::Freshdesk::SubSequence::Object
  3. EXPECTING = %i[action response resources].freeze
  4. uses :tickets_updated_since
  5. private
  6. def request_params
  7. {
  8. page: page,
  9. updated_since: updated_since,
  10. order_by: 'updated_at',
  11. order_type: :asc,
  12. }
  13. end
  14. def page
  15. page_cycle + 1
  16. end
  17. def page_cycle
  18. iteration % 300
  19. end
  20. def updated_since
  21. @updated_since ||= tickets_updated_since || '1970-01-01'
  22. return @updated_since if !new_page_cycle?
  23. @updated_since = result[:resources].last['updated_at']
  24. end
  25. def skipped_resource_id
  26. super
  27. return @skipped_resource_id if !new_page_cycle?
  28. @skipped_resource_id = result[:resources].last['id']
  29. end
  30. def new_page_cycle?
  31. return false if page_cycle != 0
  32. return false if iteration.zero?
  33. true
  34. end
  35. end