Sha256: 25327fbb2035558e7138fa09834c6f4acb14b28679a5eb4c8dd96da0c1b793fe

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

ClothesMachineUse.class_eval do
  data_miner do
    schema do
      string 'name'
      float  'annual_energy_from_electricity_for_clothes_driers'
      string 'annual_energy_from_electricity_for_clothes_driers_units'
    end
    
    process "derive from ResidentialEnergyConsumptionSurveyResponse" do
      ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
      connection.execute %{
        INSERT IGNORE INTO clothes_machine_uses(name)
        SELECT DISTINCT recs_responses.clothes_washer_use FROM recs_responses WHERE LENGTH(recs_responses.clothes_washer_use) > 0
      }
    end
    
    # sabshere 5/20/10 weird that this uses cohort
    process "precalculate annual energy use" do
      find_in_batches do |batch|
        batch.each do |record|
          record.annual_energy_from_electricity_for_clothes_driers = ResidentialEnergyConsumptionSurveyResponse.big_cohort(:clothes_machine_use => record).weighted_average :annual_energy_from_electricity_for_clothes_driers
          record.annual_energy_from_electricity_for_clothes_driers_units = 'joules'
          record.save!
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
earth-0.4.1 lib/earth/residence/clothes_machine_use/data_miner.rb
earth-0.4.0 lib/earth/residence/clothes_machine_use/data_miner.rb
earth-0.3.15 lib/earth/residence/clothes_machine_use/data_miner.rb
earth-0.3.14 lib/earth/residence/clothes_machine_use/data_miner.rb
earth-0.3.13 lib/earth/residence/clothes_machine_use/data_miner.rb