diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-06-02 10:57:50 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-06-02 10:57:50 +0100 |
commit | 2966cb5a60373b1e460b5c0b6fd42c4d32992196 (patch) | |
tree | ce856eea09a42590231e97dcacd3901aa360b5bb /lib/tasks/cleanup.rake | |
parent | 33b6e0d9a1026ba4e7909322724b25fe1de39ee1 (diff) | |
parent | 9b400100295d3f72522b368edbdc67fd7363cc61 (diff) |
Merge branch 'feature/1407-cleanup-holding-pen' into rails-3-develop
Diffstat (limited to 'lib/tasks/cleanup.rake')
-rw-r--r-- | lib/tasks/cleanup.rake | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/tasks/cleanup.rake b/lib/tasks/cleanup.rake new file mode 100644 index 000000000..9a8be9521 --- /dev/null +++ b/lib/tasks/cleanup.rake @@ -0,0 +1,20 @@ +namespace :cleanup do + + desc 'Clean up all message redelivery and destroy actions 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 (?)', + ['redeliver_incoming', + 'destroy_incoming']]) do |event| + puts event.inspect + if ! dryrun + event.destroy + end + end + end + +end |