<commit_before>class AvatarPurgeWorker

  include Sidekiq::Worker

  sidekiq_options :queue => :high
  sidekiq_options :retry => false

  def perform(record_id,klass)
    _klass = klass.constantize
    record = _klass.find(record_id)

    versions      = []
    version_types = [:id]

    version_types << :email if record.respond_to?(:email_hash)

    version_types.each do |version|
      versions << record.dynamic_avatar_path(nil, version)
    end

    cdn = NetDNARWS::NetDNA.new(
      Cloudsdale.config['cdn']['alias'],
      Cloudsdale.config['cdn']['key'],
      Cloudsdale.config['cdn']['secret']
    )

    cdn.purge(Cloudsdale.config['cdn']['avatar_zone']['id'],versions)

    record.avatar_purged = true
    record.save

    return true
  rescue Curl::Err::ConnectionFailedError
    return false
  end<commit_msg>Rescue document not found.<commit_after>class AvatarPurgeWorker

  include Sidekiq::Worker

  sidekiq_options :queue => :high
  sidekiq_options :retry => false

  def perform(record_id,klass)
    _klass = klass.constantize
    record = _klass.find(record_id)

    versions      = []
    version_types = [:id]

    version_types << :email if record.respond_to?(:email_hash)

    version_types.each do |version|
      versions << record.dynamic_avatar_path(nil, version)
    end

    cdn = NetDNARWS::NetDNA.new(
      Cloudsdale.config['cdn']['alias'],
      Cloudsdale.config['cdn']['key'],
      Cloudsdale.config['cdn']['secret']
    )

    cdn.purge(Cloudsdale.config['cdn']['avatar_zone']['id'],versions)

    record.avatar_purged = true
    record.save

    return true
  rescue Curl::Err::ConnectionFailedError
    return false
  rescue Mongoid::Errors::DocumentNotFound
    return false
  end
{'fraction_non_alphanumeric': 0.12347826086956522, 'fraction_numerical': 0.0, 'mean_word_length': 3.6775067750677506, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '4991701', 'n_tokens_mistral': 576, 'n_tokens_neox': 551, 'n_words': 98}