Sha256: ffc866119428041d32ce55268da784a75893f006ae871d1ace22bb13070d8b84

Contents?: true

Size: 617 Bytes

Versions: 2

Compression:

Stored size: 617 Bytes

Contents

namespace :rpush do
  namespace :notifications do
    desc "Delete completed notifications older than number of days (DAYS > 0)"
    task :clean => :environment do
      date = (ENV['DAYS'].blank? || ENV['DAYS'].to_i <= 0)  ? nil : Time.zone.now.end_of_day - (ENV['DAYS'].to_i).days

      if(date.nil?)
        puts "DAYS is required and must be greater than 0"
      else
        puts "BEG: Delete completed notifications before '#{date}'\n"
        deleted_count = Rpush::Notification.completed_and_older_than(date).delete_all
        puts "END: Deleted #{deleted_count} notifications"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rpush-1.0.0-java lib/tasks/rpush.rake
rpush-1.0.0 lib/tasks/rpush.rake