diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-05-21 15:14:20 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-05-21 19:25:52 +0100 |
commit | b9030012550d520ba68d16feeead35076939e71c (patch) | |
tree | ec5f810a24981173deeeb0bd4fe4a9239e3f6513 /lib | |
parent | 862437b3c05dfdecae75483106420fe4c2b9e641 (diff) |
Rake task for cleaning up old holding pen events
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/cleanup.rake | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/tasks/cleanup.rake b/lib/tasks/cleanup.rake new file mode 100644 index 000000000..c1cc6e003 --- /dev/null +++ b/lib/tasks/cleanup.rake @@ -0,0 +1,22 @@ +namespace :cleanup do + + desc 'Clean up old events (> 1 year) from the holding pen to make admin actions there faster' + task :holding_pen => :environment do + dryrun = ENV['DRYRUN'] != '0' + if dryrun + STDERR.puts "This is a dryrun - nothing will be deleted" + end + holding_pen = InfoRequest.find_by_url_title('holding_pen') + old_events = holding_pen.info_request_events.find_each(:conditions => ['event_type in (?) + AND created_at < ?', + ['redeliver_incoming', + 'destroy_incoming'], + Time.now - 1.year]) do |event| + puts event.inspect + if ! dryrun + event.destroy + end + end + end + +end |