<commit_before>require 'yaml'
require 'logger'
require 'active_record'

namespace :casino do
  namespace :cleanup do
    desc 'Remove expired service tickets.'
    task service_tickets: :environment do
      [:consumed, :unconsumed].each do |type|
        rows_affected = CASino::ServiceTicket.send("cleanup_#{type}").length
        puts "Deleted #{rows_affected} #{type} service tickets."
      end
      rows_affected = CASino::ServiceTicket.cleanup_consumed_hard
      puts "Force deleted #{rows_affected} consumed service tickets."
    end

    desc 'Remove expired proxy tickets.'
    task proxy_tickets: :environment do
      [:consumed, :unconsumed].each do |type|
        rows_affected = CASino::ProxyTicket.send("cleanup_#{type}").length
        puts "Deleted #{rows_affected} #{type} proxy tickets."
      end
    end<commit_msg>Fix rows affected number<commit_after>require 'yaml'
require 'logger'
require 'active_record'

namespace :casino do
  namespace :cleanup do
    desc 'Remove expired service tickets.'
    task service_tickets: :environment do
      [:consumed, :unconsumed].each do |type|
        rows_affected = CASino::ServiceTicket.send("cleanup_#{type}")
        if rows_affected.respond_to? :length
          rows_affected = rows_affected.length
        end
        puts "Deleted #{rows_affected} #{type} service tickets."
      end
      rows_affected = CASino::ServiceTicket.cleanup_consumed_hard
      puts "Force deleted #{rows_affected} consumed service tickets."
    end

    desc 'Remove expired proxy tickets.'
    task proxy_tickets: :environment do
      [:consumed, :unconsumed].each do |type|
        rows_affected = CASino::ProxyTicket.send("cleanup_#{type}").length
        puts "Deleted #{rows_affected} #{type} proxy tickets."
      end
    end
{'fraction_non_alphanumeric': 0.1019036954087346, 'fraction_numerical': 0.0, 'mean_word_length': 3.558673469387755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2987163', 'n_tokens_mistral': 537, 'n_tokens_neox': 505, 'n_words': 142}