<commit_before>class MiqReport::Formats
  format_hash = YAML.load_file(ApplicationRecord::FIXTURE_DIR.join('miq_report_formats.yml')).freeze
  FORMATS                = format_hash[:formats].freeze
  DEFAULTS_AND_OVERRIDES = format_hash[:defaults_and_overrides].freeze

  def self.available_formats_for(column, suffix, datatype)
    is_break_sfx = (suffix && MiqReport.is_break_suffix?(suffix))
    FORMATS.each_with_object({}) do |(format_name, properties), result|
      # Ignore formats that don't include suffix if the column name has a break suffix
      next if is_break_sfx && (properties[:suffixes].nil? || !properties[:suffixes].include?(suffix.to_sym))
      next unless (properties[:columns] && properties[:columns].include?(column)) ||
                  (properties[:sub_types] && properties[:sub_types].include?(sub_type(column))) ||
                  (properties[:data_types] && properties[:data_types].include?(datatype)) ||
                  (properties[:suffixes] && properties[:suffixes].include?(suffix.to_sym))
      result[format_name] = properties[:description]
    end
  end

  def self.default_format_for(column, suffix, datatype)
    DEFAULTS_AND_OVERRIDES[:formats_by_suffix][suffix] ||
      DEFAULTS_AND_OVERRIDES[:formats_by_column][column] ||
      DEFAULTS_AND_OVERRIDES[:formats_by_sub_type][sub_type(column)] ||
      DEFAULTS_AND_OVERRIDES[:formats_by_data_type][datatype]
  end

  def self.default_format_details_for(column, suffix, datatype)
    format = FORMATS[default_format_for(column, suffix, datatype)]
    if format
      format = format.deep_clone # Make sure we don't taint the original
      if DEFAULTS_AND_OVERRIDES[:precision_by_column].key?(column.to_sym)
        format[:precision] = DEFAULTS_AND_OVERRIDES[:precision_by_column][column.to_sym]<commit_msg>The sub_type itself (when valid) should be offered as an option<commit_after>class MiqReport::Formats
  format_hash = YAML.load_file(ApplicationRecord::FIXTURE_DIR.join('miq_report_formats.yml')).freeze
  FORMATS                = format_hash[:formats].freeze
  DEFAULTS_AND_OVERRIDES = format_hash[:defaults_and_overrides].freeze

  def self.available_formats_for(column, suffix, datatype)
    is_break_sfx = (suffix && MiqReport.is_break_suffix?(suffix))
    FORMATS.each_with_object({}) do |(format_name, properties), result|
      # Ignore formats that don't include suffix if the column name has a break suffix
      next if is_break_sfx && (properties[:suffixes].nil? || !properties[:suffixes].include?(suffix.to_sym))
      next unless (properties[:columns] && properties[:columns].include?(column)) ||
                  (properties[:sub_types] && properties[:sub_types].include?(sub_type(column))) ||
                  (properties[:data_types] && properties[:data_types].include?(datatype)) ||
                  (properties[:suffixes] && properties[:suffixes].include?(suffix.to_sym)) ||
                  (format_name == sub_type(column))

      result[format_name] = properties[:description]
    end
  end

  def self.default_format_for(column, suffix, datatype)
    DEFAULTS_AND_OVERRIDES[:formats_by_suffix][suffix] ||
      DEFAULTS_AND_OVERRIDES[:formats_by_column][column] ||
      DEFAULTS_AND_OVERRIDES[:formats_by_sub_type][sub_type(column)] ||
      DEFAULTS_AND_OVERRIDES[:formats_by_data_type][datatype]
  end

  def self.default_format_details_for(column, suffix, datatype)
    format = FORMATS[default_format_for(column, suffix, datatype)]
    if format
      format = format.deep_clone # Make sure we don't taint the original
      if DEFAULTS_AND_OVERRIDES[:precision_by_column].key?(column.to_sym)
        format[:precision] = DEFAULTS_AND_OVERRIDES[:precision_by_column][column.to_sym]
{'fraction_non_alphanumeric': 0.11733046286329386, 'fraction_numerical': 0.0, 'mean_word_length': 4.789719626168225, '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': '5194123', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1167, 'n_words': 181}