<commit_before>#-------------------------------------------------------------------------------
#
# CapitalProjectBuilder
#
# Analyzes an organizations's assets and generates a set of capital projects
# for the organization.
#
#-------------------------------------------------------------------------------
class AssetFleetBuilder
  attr_accessor :asset_fleet_type
  attr_accessor :organization
  attr_accessor :query


  #-----------------------------------------------------------------------------
  #
  # Instance Methods
  #
  #-----------------------------------------------------------------------------

  def group_by_fields(fleet_type)
    group_by_fields = fleet_type.standard_group_by_fields + ['primary_modes.fta_mode_type_id as primary_fta_mode_type_id']

    if fleet_type.class_name == 'ServiceVehicle'
      group_by_fields << ['secondary_modes.fta_mode_types_str as secondary_fta_mode_types']
    else
      group_by_fields << ['secondary_modes.fta_mode_type_id as secondary_fta_mode_type_id','IF(transit_assets.pcnt_capital_responsibility > 0, "YES", "NO") as direct_capital_responsibility', 'service_types.fta_service_type_id as primary_fta_service_type_id', 'secondary_service_types.fta_service_type_id as secondary_fta_service_type_id']
    end

    group_by_fields.flatten
  end

  def asset_query(fleet_type, organization)

    query = fleet_type.class_name.constantize
                .joins('LEFT JOIN (SELECT * FROM assets_fta_mode_types WHERE is_primary=1) AS primary_modes ON transam_assets.id = primary_modes.transam_asset_id')
                .where(organization: organization)<commit_msg>only add assets not in transfer when building fleets<commit_after>#-------------------------------------------------------------------------------
#
# CapitalProjectBuilder
#
# Analyzes an organizations's assets and generates a set of capital projects
# for the organization.
#
#-------------------------------------------------------------------------------
class AssetFleetBuilder
  attr_accessor :asset_fleet_type
  attr_accessor :organization
  attr_accessor :query


  #-----------------------------------------------------------------------------
  #
  # Instance Methods
  #
  #-----------------------------------------------------------------------------

  def group_by_fields(fleet_type)
    group_by_fields = fleet_type.standard_group_by_fields + ['primary_modes.fta_mode_type_id as primary_fta_mode_type_id']

    if fleet_type.class_name == 'ServiceVehicle'
      group_by_fields << ['secondary_modes.fta_mode_types_str as secondary_fta_mode_types']
    else
      group_by_fields << ['secondary_modes.fta_mode_type_id as secondary_fta_mode_type_id','IF(transit_assets.pcnt_capital_responsibility > 0, "YES", "NO") as direct_capital_responsibility', 'service_types.fta_service_type_id as primary_fta_service_type_id', 'secondary_service_types.fta_service_type_id as secondary_fta_service_type_id']
    end

    group_by_fields.flatten
  end

  def asset_query(fleet_type, organization)

    query = fleet_type.class_name.constantize
                .joins('LEFT JOIN (SELECT * FROM assets_fta_mode_types WHERE is_primary=1) AS primary_modes ON transam_assets.id = primary_modes.transam_asset_id')
                .where(organization: organization)
                .where('asset_tag != object_key')
{'fraction_non_alphanumeric': 0.24587211047733412, 'fraction_numerical': 0.0012008405884118883, 'mean_word_length': 2.0995348837209304, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '910967', 'n_tokens_mistral': 936, 'n_tokens_neox': 881, 'n_words': 165}