# frozen_string_literal: true

namespace :debshots do
  desc 'Remove log entries older than a month'

  task purge_old_logs: :environment do
    Rails.logger = Logger.new($stdout)
    Rails.logger.level = Logger::INFO
    # Rails.logger.level = Logger::DEBUG

    Rails.logger.info 'Remove log entries that are older than a month'

    count = Log.where('created_at < ?', 1.month.ago).delete_all

    Rails.logger.info "#{count} log records purged"
  end
end
