trabajo-afectivo/app/models/http_log.rb

34 lines
669 B
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
2016-04-18 00:02:31 +00:00
class HttpLog < ApplicationModel
store :request
store :response
# See https://github.com/zammad/zammad/issues/2100
before_save :messages_to_utf8
2016-04-18 00:02:31 +00:00
=begin
cleanup old http logs
HttpLog.cleanup
optional you can put the max oldest chat entries as argument
2016-04-18 00:02:31 +00:00
HttpLog.cleanup(1.month)
=end
def self.cleanup(diff = 1.month)
HttpLog.where('created_at < ?', Time.zone.now - diff).delete_all
true
end
private
def messages_to_utf8
request.transform_values! { |v| v.try(:utf8_encode) || v }
response.transform_values! { |v| v.try(:utf8_encode) || v }
end
2016-04-18 00:02:31 +00:00
end