Sha256: deaaa1bd36bbb5cec786a642ef228a063053def6e2fe0270a85d3656f375b0cb

Contents?: true

Size: 1.32 KB

Versions: 9

Compression:

Stored size: 1.32 KB

Contents

class ClothesMachineUse < ActiveRecord::Base
  set_primary_key :name
  
  has_many :residences
  has_many :residential_energy_consumption_survey_responses

  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 residential_energy_consumption_survey_responses.clothes_washer_use FROM residential_energy_consumption_survey_responses WHERE LENGTH(residential_energy_consumption_survey_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

9 entries across 9 versions & 1 rubygems

Version Path
earth-0.0.27 lib/earth/residence/clothes_machine_use.rb
earth-0.0.26 lib/earth/residence/clothes_machine_use.rb
earth-0.0.24 lib/earth/residence/clothes_machine_use.rb
earth-0.0.23 lib/earth/residence/clothes_machine_use.rb
earth-0.0.22 lib/earth/residence/clothes_machine_use.rb
earth-0.0.21 lib/earth/residence/clothes_machine_use.rb
earth-0.0.20 lib/earth/residence/clothes_machine_use.rb
earth-0.0.19 lib/earth/residence/clothes_machine_use.rb
earth-0.0.18 lib/earth/residence/clothes_machine_use.rb