Implemented issue #1254 - Feature Request: clear caller log.

This commit is contained in:
Martin Edenhofer 2017-07-14 17:20:48 +02:00
parent daaf1525cd
commit 547f002f71
3 changed files with 45 additions and 0 deletions

View file

@ -358,5 +358,23 @@ returns
)
}
end
=begin
cleanup caller logs
Cti::Log.cleanup
optional you can put the max oldest chat entries as argument
Cti::Log.cleanup(12.months)
=end
def self.cleanup(diff = 12.months)
Cti::Log.where('created_at < ?', Time.zone.now - diff).delete_all
true
end
end
end

View file

@ -0,0 +1,18 @@
class CleanupCtiLog < ActiveRecord::Migration
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
Scheduler.create_if_not_exists(
name: 'Cleanup Cti::Log',
method: 'Cti::Log.cleanup',
period: 1.month,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
end
end

View file

@ -156,6 +156,15 @@ Scheduler.create_if_not_exists(
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Cleanup Cti::Log',
method: 'Cti::Log.cleanup',
period: 1.month,
prio: 2,
active: true,
updated_by_id: 1,
created_by_id: 1,
)
Scheduler.create_if_not_exists(
name: 'Import Jobs',
method: 'ImportJob.start_registered',