Sha256: 0ca915765597c824ade51d21a1240e080cb279e1e7b66c7851ac7933a8d5f6c9

Contents?: true

Size: 802 Bytes

Versions: 62

Compression:

Stored size: 802 Bytes

Contents

ResidenceAppliance.class_eval do
  data_miner do
    schema Earth.database_options do
      string   'name'
      float    'annual_energy_from_electricity'
      string   'annual_energy_from_electricity_units'
    end

    process "Derive from residential energy consumption survey responses" do
      ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
      ResidentialEnergyConsumptionSurveyResponse.column_names.grep(/_count$/).each do |column_name|
        appliance_name = column_name.sub '_count', ''
        appliance = find_or_create_by_name appliance_name
        appliance.annual_energy_from_electricity = ResidentialEnergyConsumptionSurveyResponse.weighted_average "annual_energy_from_electricity_for_#{appliance_name.pluralize}"
        appliance.save!
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 2 rubygems

Version Path
earth-0.4.12 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.4.11 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.4.10 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.4.9 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.4.8 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.4.7 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.4.6 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.4.5 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.4.4 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.4.3 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.4.2 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.4.1 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.4.0 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.3.15 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.3.14 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.3.13 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.3.11 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.3.10 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.3.9 lib/earth/residence/residence_appliance/data_miner.rb
earth-0.3.8 lib/earth/residence/residence_appliance/data_miner.rb