<commit_before>class AvatarDispatch

  BASE_SIZES    = Array.new(9){ |n| 2 ** (n + 1) }.last(7)
  SPECIAL_SIZES = [24,40,50,70,200]
  ALLOWED_SIZES = (BASE_SIZES + SPECIAL_SIZES).uniq.sort
  PATH_MATCH    = /\/(?<model>user|app|cloud)\/((?<md5>[0-9a-f]{32})|(?<bson>[0-9a-fA-F]{24}))\.(?<format>png)/
  DOMAIN_MATCH  = /^(avatar)\..*$/
  TIMESTAMP      = DateTime.parse("2012-01-01").to_i
  HTTP_TIMESTAMP = DateTime.parse("2012-01-01").httpdate
  REDIS_EXPIRE   = 12.hours

  def initialize(app)
    @app = app
  end

  def call(env)
    request = Rack::Request.new(env.deep_dup)
    if DOMAIN_MATCH.match(request.host)
      if path_match = PATH_MATCH.match(request.path)

        options = Hash.new

        if path_match[:md5]
          options[:type]  = :email_hash
          options[:id]    = path_match[:md5]
        elsif path_match[:bson]
          options[:type]  = :id
          options[:id]    = path_match[:bson]
        end

        options[:model] = path_match[:model].to_sym
        options[:size]  = request.params["s"].try(:to_i) || 256<commit_msg>Remove redundant constants.<commit_after>class AvatarDispatch

  BASE_SIZES    = Array.new(9){ |n| 2 ** (n + 1) }.last(7)
  SPECIAL_SIZES = [24,40,50,70,200]
  ALLOWED_SIZES = (BASE_SIZES + SPECIAL_SIZES).uniq.sort
  PATH_MATCH    = /\/(?<model>user|app|cloud)\/((?<md5>[0-9a-f]{32})|(?<bson>[0-9a-fA-F]{24}))\.(?<format>png)/
  DOMAIN_MATCH  = /^(avatar)\..*$/
  REDIS_EXPIRE   = 12.hours

  def initialize(app)
    @app = app
  end

  def call(env)
    request = Rack::Request.new(env.deep_dup)
    if DOMAIN_MATCH.match(request.host)
      if path_match = PATH_MATCH.match(request.path)

        options = Hash.new

        if path_match[:md5]
          options[:type]  = :email_hash
          options[:id]    = path_match[:md5]
        elsif path_match[:bson]
          options[:type]  = :id
          options[:id]    = path_match[:bson]
        end

        options[:model] = path_match[:model].to_sym
        options[:size]  = request.params["s"].try(:to_i) || 256
{'fraction_non_alphanumeric': 0.17534381139489194, 'fraction_numerical': 0.03831041257367387, 'mean_word_length': 2.8074766355140186, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3377380', 'n_tokens_mistral': 873, 'n_tokens_neox': 784, 'n_words': 113}