can_latest_change.rb 458 B

12345678910111213141516171819202122232425
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module ApplicationModel::CanLatestChange
  3. extend ActiveSupport::Concern
  4. # methods defined here are going to extend the class, not the instance of it
  5. class_methods do
  6. =begin
  7. get latest updated_at object timestamp
  8. latest_change = object.latest_change
  9. returns
  10. result = timestamp
  11. =end
  12. def latest_change
  13. maximum(:updated_at)&.to_fs(:nsec)
  14. end
  15. end
  16. end