Sha256: d860e1996b195e9ff5391b12f26663bc27581bd1fe3a3011c47fdb06c942301d

Contents?: true

Size: 1.55 KB

Versions: 19

Compression:

Stored size: 1.55 KB

Contents

Carrier.class_eval do
  data_miner do
    import "a list of shipping companies and their characteristics",
           :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdG1ONU1HZDdZTFJNclFYVkRzR0k5Z2c&hl=en&gid=0&output=csv' do
      key   'name'
      store 'package_volume'
      store 'route_inefficiency_factor'
      store 'transport_emission_factor', :units_field_name => 'transport_emission_factor_units'
      store 'corporate_emission_factor', :units_field_name => 'corporate_emission_factor_units'
    end
    
    # TODO: derive package volume, route inefficiency factor, and transport emission factor
    # process "derive package volume, route inefficiency factor, and transport emission factor from CarrierModes" do
    #   CarrierMode.run_data_miner!
    #   
    #   carrier_modes = CarrierMode.arel_table
    #   carriers = Carrier.arel_table
    #   conditional_relation = carrier_modes[:include_in_fallbacks].and(carriers[:name].eq(carrier_modes[:carrier_name]))
    #   
    #   update_all "package_volume            = (#{carriers.project(sum(carriers[:package_volume]).where(conditional_relation)).to_sql})"
    #   update_all "route_inefficiency_factor = (#{CarrierMode.weighted_average_relation(:route_inefficiency_factor, :weighted_by => :package_volume).where(conditional_relation).to_sql})"
    #   update_all "transport_emission_factor = (#{CarrierMode.weighted_average_relation(:transport_emission_factor, :weighted_by => :package_volume).where(conditional_relation).to_sql})"
    #   what about transport_emission_factor_units?
    # end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
earth-0.11.10 lib/earth/shipping/carrier/data_miner.rb
earth-0.11.9 lib/earth/shipping/carrier/data_miner.rb
earth-0.11.8 lib/earth/shipping/carrier/data_miner.rb
earth-0.11.7 lib/earth/shipping/carrier/data_miner.rb
earth-0.11.6 lib/earth/shipping/carrier/data_miner.rb
earth-0.11.5 lib/earth/shipping/carrier/data_miner.rb
earth-0.11.4 lib/earth/shipping/carrier/data_miner.rb
earth-0.11.3 lib/earth/shipping/carrier/data_miner.rb
earth-0.11.2 lib/earth/shipping/carrier/data_miner.rb
earth-0.11.1 lib/earth/shipping/carrier/data_miner.rb
earth-0.11.0 lib/earth/shipping/carrier/data_miner.rb
earth-0.7.0 lib/earth/shipping/carrier/data_miner.rb
earth-0.6.6 lib/earth/shipping/carrier/data_miner.rb
earth-0.6.5 lib/earth/shipping/carrier/data_miner.rb
earth-0.6.4 lib/earth/shipping/carrier/data_miner.rb
earth-0.6.3 lib/earth/shipping/carrier/data_miner.rb
earth-0.6.2 lib/earth/shipping/carrier/data_miner.rb
earth-0.6.1 lib/earth/shipping/carrier/data_miner.rb
earth-0.6.0 lib/earth/shipping/carrier/data_miner.rb