<commit_before>class TenantQuota < ActiveRecord::Base
  belongs_to :tenant

  QUOTA_BASE = {
    :cpu_allocated => {
      :unit          => :mhz,
      :format        => :mhz,
      :text_modifier => "Mhz".freeze
    },
    :mem_allocated => {
      :unit          => :bytes,
      :format        => :gigabytes_human,
      :text_modifier => "GB".freeze
    },
    :storage_allocated => {
      :unit          => :bytes,
      :format        => :gigabytes_human,
      :text_modifier => "GB".freeze
    },
    :vms_allocated => {
      :unit          => :fixnum,
      :format        => :general_number_precision_0,
      :text_modifier => "Count".freeze
    },
    :templates_allocated => {
      :unit          => :fixnum,
      :format        => :general_number_precision_0,
      :text_modifier => "Count".freeze
    }
  }

  NAMES = QUOTA_BASE.stringify_keys

  validates :name, :inclusion => {:in => NAMES}
  validates :unit, :value, :presence => true

  def self.quota_definitions
    return @quota_definitions if @quota_definitions

    @quota_definitions = QUOTA_BASE.each_with_object({}) do |q, h|
      name, value = q
      h[name] = value.merge(:description => I18n.t("dictionary.tenants.#{name}"), :value => nil)
      h
    end
  end

  def format
    self.class.quota_definitions.fetch_path(name.to_sym, :format).to_s
  end

  def default_unit
    self.class.quota_definitions.fetch_path(name.to_sym, :unit).to_s
  end
end<commit_msg>tenant_quota: store only keys for NAMES<commit_after>class TenantQuota < ActiveRecord::Base
  belongs_to :tenant

  QUOTA_BASE = {
    :cpu_allocated => {
      :unit          => :mhz,
      :format        => :mhz,
      :text_modifier => "Mhz".freeze
    },
    :mem_allocated => {
      :unit          => :bytes,
      :format        => :gigabytes_human,
      :text_modifier => "GB".freeze
    },
    :storage_allocated => {
      :unit          => :bytes,
      :format        => :gigabytes_human,
      :text_modifier => "GB".freeze
    },
    :vms_allocated => {
      :unit          => :fixnum,
      :format        => :general_number_precision_0,
      :text_modifier => "Count".freeze
    },
    :templates_allocated => {
      :unit          => :fixnum,
      :format        => :general_number_precision_0,
      :text_modifier => "Count".freeze
    }
  }

  NAMES = QUOTA_BASE.keys.map(&:to_s)

  validates :name, :inclusion => {:in => NAMES}
  validates :unit, :value, :presence => true

  def self.quota_definitions
    return @quota_definitions if @quota_definitions

    @quota_definitions = QUOTA_BASE.each_with_object({}) do |q, h|
      name, value = q
      h[name] = value.merge(:description => I18n.t("dictionary.tenants.#{name}"), :value => nil)
      h
    end
  end

  def format
    self.class.quota_definitions.fetch_path(name.to_sym, :format).to_s
  end

  def default_unit
    self.class.quota_definitions.fetch_path(name.to_sym, :unit).to_s
  end
end
{'fraction_non_alphanumeric': 0.13447098976109215, 'fraction_numerical': 0.0027303754266211604, 'mean_word_length': 2.3884393063583813, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 53, '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': '3189168', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1025, 'n_words': 176}