<commit_before>require 'deliveryboy/client'

class ArchiveMail
  # compulsary stuff
  include Deliveryboy::Maildir::Plugin

  def initialize(config)
    @dirname = config["dirname"]
    @limit   = config["limit"]
    File.makedirs(@dirname)
  end

  def handle(tmail_object)
    filename = Deliveryboy::Client.queue(tmail_object.to_s, @dirname)
    logger.debug "saved at #{filename}"
    if @limit
      files = Dir[File.join(@dirname, '**', '*.*.*')]
      if files.length > @limit
        files.sort_by {|f| File.mtime(f) }[@limit..-1].each do |ancient_file|
          File.delete(ancient_file)
        end
      end
    end
  end

  # optional stuff
  include Deliveryboy::Loggable
end<commit_msg>bugfix sort order<commit_after>require 'deliveryboy/client'

class ArchiveMail
  # compulsary stuff
  include Deliveryboy::Maildir::Plugin

  def initialize(config)
    @dirname = config["dirname"]
    @limit   = config["limit"]
    File.makedirs(@dirname)
  end

  def handle(tmail_object)
    filename = Deliveryboy::Client.queue(tmail_object.to_s, @dirname)
    logger.debug "saved at #{filename}"
    if @limit
      files = Dir[File.join(@dirname, '**', '*.*.*')]
      if files.length > @limit
        files.sort_by {|f| File.mtime(f) }[0...files.length-@limit].each do |ancient_file|
          File.delete(ancient_file)
        end
      end
    end
  end

  # optional stuff
  include Deliveryboy::Loggable
end
{'fraction_non_alphanumeric': 0.1324876673713883, 'fraction_numerical': 0.0014094432699083862, 'mean_word_length': 3.2136498516320473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6503963', 'n_tokens_mistral': 478, 'n_tokens_neox': 459, 'n_words': 97}