Sha256: e90c4b2638da185995714923e74c5a5482eec6220aece836c4d6ebe34be40f79

Contents?: true

Size: 720 Bytes

Versions: 1

Compression:

Stored size: 720 Bytes

Contents

namespace :devise_guests do
  # task to clean out old guest users
  # rake devise_guests:delete_old_guest_users[days_old]
  # example cron entry to delete users older than 7 days at 2:00 AM every day:
  # 0 2 * * * cd /path/to/your/app && /path/to/rake devise_guests:delete_old_guest_users[7] RAILS_ENV=your_env
  desc "Removes entries in the users table for guest users that are older than the number of days given."
  task :delete_old_guest_users, [:days_old, :batch_size] => [:environment] do |t, args|
    args.with_defaults(days_old: 7, batch_size: 1000)
    User
      .where("guest = ? and updated_at < ?", true, Time.now - args[:days_old].to_i.days)
      .find_each(batch_size: batch_size, &:destroy)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise-guests-0.8.2 lib/railties/devise_guests.rake