<commit_before>class FacilityPrimaryAssetTableView  < ActiveRecord::Base

  include TransamFormatHelper

  def readonly?
    true
  end

  #These associations are to more quickly support the access of recent asset events for the model
  belongs_to :facility
  belongs_to :policy

  def self.get_default_table_headers
    ["Asset ID", "Organization", "Facility Name", "Facility Categorization*", "Component - Sub-Component Type*",
     "Year", "Class", "Type", "Status", "ESL", "Last Life Cycle Action", "Life Cycle Action Date"]
  end

  def self.get_all_table_headers
    ["Asset ID", "Organization", "Facility Name", "Facility Categorization*", "Component - Sub-Component Type*",
     "Year", "Class", "Type", "Status", "ESL", "Last Life Cycle Action", "Life Cycle Action Date",
     "External ID", "Subtype*", "Funding Program (largest%)", "Cost (Purchase)", "In Service Date", "Direct Capital Responsibility", "Description*",
     "Asset Group", "Service Life - Current", "TERM Condition", "TERM Rating", "Date of Condition Assessment",
     "Replace / Rehab Policy (ESL)", "ESL - Adjusted", "Rebuild / Rehab Type", "Date of Rebuild / Rehab",
     "Location", "Current Book Value", "Replacement Status", "Replacement Policy Year",
     "Replacement Actual Year", "Scheduled Replacement Cost"]
  end

  def self.format_methods_to_sort_order_columns(sort_name)
    case sort_name
    when 'manufacturer'
      return 'transam_asset_manufacturer_name'
    when 'model'
      return 'transam_asset_other_manufacturer_model'
    when 'age'
      return 'transam_asset_in_service_date'
    when 'status'
      return 'most_recent_service_status_event_service_status_type_name'
    when 'replacement_status'
      return 'most_recent_early_replacement_event_replacement_status_type_name'
    when 'policy_replacement_year_as_fiscal_year'
      return 'transam_asset_policy_replacement_year'
    when 'scheduled_replacement_year_as_fiscal_year'
      return 'transam_asset_scheduled_replacement_year'
    end

    return sort_name
  end

  def component_or_sub_component

    if !self.facility_component_type_name.nil?
      return 'Component'
    elsif !self.facility_subcomponent_type_name.nil?
      return 'Sub-Component'
    end
    return 'Primary Facility'
  end

  def component_or_sub_component_type
    if !self.facility_component_type_name.nil?
      return self.facility_component_type_name
    elsif !self.facility_subcomponent_type_name.nil?
      return self.facility_subcomponent_type_name
    end
    return nil
  end

  def manufacturer
    if(self.transam_asset_manufacturer_name == "Other")
      return self.transam_asset_other_manufacturer
    else
      return "#{self.transam_asset_manufacturer_code} - #{self.transam_asset_manufacturer_name}"
    end
  end

  def model
    if(self.transam_asset_manufacturer_model_name == "Other")
      return self.transam_asset_other_manufacturer_model
    else
      return self.transam_asset_manufacturer_model_name
    end
  end

  def status
    if(self.service_status_event_id.nil?)
      return 'No Service Status Event Recorded'
    else
      self.most_recent_service_status_event_service_status_type_name
    end
  end<commit_msg>TTPLAT-221 updating the facilities table and scripts to use the correct fields for subtype category and categorization.<commit_after>class FacilityPrimaryAssetTableView  < ActiveRecord::Base

  include TransamFormatHelper

  def readonly?
    true
  end

  #These associations are to more quickly support the access of recent asset events for the model
  belongs_to :facility
  belongs_to :policy

  def self.get_default_table_headers
    ["Asset ID", "Organization", "Facility Name", "Facility Categorization*", "Component - Sub-Component Type*",
     "Year", "Class", "Type", "Status", "ESL", "Last Life Cycle Action", "Life Cycle Action Date"]
  end

  def self.get_all_table_headers
    ["Asset ID", "Organization", "Facility Name", "Facility Categorization*", "Component - Sub-Component Type*",
     "Year", "Class", "Type", "Status", "ESL", "Last Life Cycle Action", "Life Cycle Action Date",
     "External ID", "Subtype*", "Funding Program (largest%)", "Cost (Purchase)", "In Service Date", "Direct Capital Responsibility", "Description*",
     "Asset Group", "Service Life - Current", "TERM Condition", "TERM Rating", "Date of Condition Assessment",
     "Replace / Rehab Policy (ESL)", "ESL - Adjusted", "Rebuild / Rehab Type", "Date of Rebuild / Rehab",
     "Location", "Current Book Value", "Replacement Status", "Replacement Policy Year",
     "Replacement Actual Year", "Scheduled Replacement Cost"]
  end

  def self.format_methods_to_sort_order_columns(sort_name)
    case sort_name
    when 'manufacturer'
      return 'transam_asset_manufacturer_name'
    when 'model'
      return 'transam_asset_other_manufacturer_model'
    when 'age'
      return 'transam_asset_in_service_date'
    when 'status'
      return 'most_recent_service_status_event_service_status_type_name'
    when 'replacement_status'
      return 'most_recent_early_replacement_event_replacement_status_type_name'
    when 'policy_replacement_year_as_fiscal_year'
      return 'transam_asset_policy_replacement_year'
    when 'scheduled_replacement_year_as_fiscal_year'
      return 'transam_asset_scheduled_replacement_year'
    end

    return sort_name
  end

  def component_or_sub_component

    if !self.facility_component_type_name.nil?
      return 'Component'
    elsif !self.facility_component_subtype_name.nil?
      return 'Sub-Component'
    end
    return 'Primary Facility'
  end

  def component_or_sub_component_type
    if !self.facility_component_type_name.nil?
      return self.facility_component_type_name
    elsif !self.facility_component_subtype_name.nil?
      return self.facility_component_subtype_name
    end
    return nil
  end

  def manufacturer
    if(self.transam_asset_manufacturer_name == "Other")
      return self.transam_asset_other_manufacturer
    else
      return "#{self.transam_asset_manufacturer_code} - #{self.transam_asset_manufacturer_name}"
    end
  end

  def model
    if(self.transam_asset_manufacturer_model_name == "Other")
      return self.transam_asset_other_manufacturer_model
    else
      return self.transam_asset_manufacturer_model_name
    end
  end

  def status
    if(self.service_status_event_id.nil?)
      return 'No Service Status Event Recorded'
    else
      self.most_recent_service_status_event_service_status_type_name
    end
  end
{'fraction_non_alphanumeric': 0.08217913204062789, 'fraction_numerical': 0.0004616805170821791, 'mean_word_length': 4.357790601813685, 'pattern_counts': {'":': 0, '<': 5, '<?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': '245953', 'n_tokens_mistral': 2031, 'n_tokens_neox': 1957, 'n_words': 491}