checks_reopen_after_certain_time.rb 942 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. # Adds new and updated tickets to the reopen log processing.
  3. module Ticket::ChecksReopenAfterCertainTime
  4. extend ActiveSupport::Concern
  5. included do
  6. def reopen_after_certain_time?
  7. # No reopen time is configured.
  8. return false if !reopen_time_in_days_configured?
  9. # Ticket is not closed.
  10. return false if !close_time
  11. # We missed the possible time frame to reopen, sorry.
  12. return false if !reopen_in_configured_time?
  13. true
  14. end
  15. private
  16. def reopen_time_in_days_configured?
  17. return false if group.reopen_time_in_days.blank?
  18. return false if !group.reopen_time_in_days.positive?
  19. true
  20. end
  21. def close_time
  22. last_close_at || close_at
  23. end
  24. def reopen_in_configured_time?
  25. ((Time.zone.now - close_time).to_i / (24 * 60 * 60)) < group.reopen_time_in_days
  26. end
  27. end
  28. end