period_working_minutes.rb 584 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class Escalation
  3. class PeriodWorkingMinutes
  4. def initialize(start_time, end_time, ticket, biz)
  5. @start_time = start_time
  6. @end_time = end_time
  7. @ticket = ticket
  8. @biz = biz
  9. end
  10. def period_working_minutes
  11. @biz.within(timeframe_start, timeframe_end).in_minutes
  12. end
  13. private
  14. def timeframe_start
  15. [@ticket.created_at, @start_time].compact.max
  16. end
  17. def timeframe_end
  18. [@ticket.close_at, @end_time].compact.min
  19. end
  20. end
  21. end