<commit_before>class FtaAssetClass < ApplicationRecord

  belongs_to  :fta_asset_category

  # All types that are available
  scope :active, -> { where(:active => true) }

  def to_s
    name
  end

  # override column in database as other
  def class_name(opts: {},assets: nil)
    if fta_asset_category.name == 'Facilities'
      if opts[:is_component].to_i != Facility::CATEGORIZATION_PRIMARY
        'FacilityComponent'
      elsif assets.present? && (assets.very_specific.class.to_s.include? 'TransitComponent')
        'FacilityComponent'
      else
        read_attribute(:class_name)
      end
    elsif fta_asset_category.name == 'Infrastructure'
      if assets.present? && (assets.very_specific.class.to_s.include? 'TransitComponent')
        'InfrastructureComponent'
      else
        read_attribute(:class_name)
      end
    else<commit_msg>TTPLAT-667 TTPLAT-685 fix bad refactor where you check if component. very_specific might already be cached highest class or class pulled from DB table name so you just need to check if class contains Component not the whole class name<commit_after>class FtaAssetClass < ApplicationRecord

  belongs_to  :fta_asset_category

  # All types that are available
  scope :active, -> { where(:active => true) }

  def to_s
    name
  end

  # override column in database as other
  def class_name(opts: {},assets: nil)
    if fta_asset_category.name == 'Facilities'
      if opts[:is_component].to_i != Facility::CATEGORIZATION_PRIMARY
        'FacilityComponent'
      elsif assets.present? && (assets.very_specific.class.to_s.include? 'Component') # asset.very_specific class might be already highest class since cached not just the class as determined from DB table name so check if contains Component and can be either FacilityComponent or TransitComponent
        'FacilityComponent'
      else
        read_attribute(:class_name)
      end
    elsif fta_asset_category.name == 'Infrastructure'
      if assets.present? && (assets.very_specific.class.to_s.include? 'Component')
        'InfrastructureComponent'
      else
        read_attribute(:class_name)
      end
    else
{'fraction_non_alphanumeric': 0.07833020637898687, 'fraction_numerical': 0.0028142589118198874, 'mean_word_length': 3.5479744136460556, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5082507', 'n_tokens_mistral': 618, 'n_tokens_neox': 600, 'n_words': 178}