Sha256: f10e3a9857f9e56fef80ea1d8f283196eba019806f113c7fff33c059058859f7

Contents?: true

Size: 1.29 KB

Versions: 28

Compression:

Stored size: 1.29 KB

Contents

class DishwasherUse < 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_dishwashers'
      string 'annual_energy_from_electricity_for_dishwashers_units'
    end
    
    process "derive from ResidentialEnergyConsumptionSurveyResponse" do
      ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
      connection.execute %{
        INSERT IGNORE INTO dishwasher_uses(name)
        SELECT DISTINCT residential_energy_consumption_survey_responses.dishwasher_use_id FROM residential_energy_consumption_survey_responses WHERE LENGTH(residential_energy_consumption_survey_responses.dishwasher_use_id) > 0
      }
    end
    
    # sabshere 5/25/10 weird that this uses cohort
    process "precalculate annual energy" do
      find_in_batches do |batch|
        batch.each do |record|
          record.annual_energy_from_electricity_for_dishwashers = ResidentialEnergyConsumptionSurveyResponse.big_cohort(:dishwasher_use => record).weighted_average :annual_energy_from_electricity_for_dishwashers
          record.annual_energy_from_electricity_for_dishwashers_units = 'joules'
          record.save!
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
earth-0.1.2 lib/earth/residence/dishwasher_use.rb
earth-0.1.1 lib/earth/residence/dishwasher_use.rb
earth-0.1.0 lib/earth/residence/dishwasher_use.rb
earth-0.0.43 lib/earth/residence/dishwasher_use.rb
earth-0.0.42 lib/earth/residence/dishwasher_use.rb
earth-0.0.41 lib/earth/residence/dishwasher_use.rb
earth-0.0.40 lib/earth/residence/dishwasher_use.rb
earth-0.0.39 lib/earth/residence/dishwasher_use.rb
earth-0.0.38 lib/earth/residence/dishwasher_use.rb
earth-0.0.37 lib/earth/residence/dishwasher_use.rb
earth-0.0.36 lib/earth/residence/dishwasher_use.rb
earth-0.0.35 lib/earth/residence/dishwasher_use.rb
earth-0.0.34 lib/earth/residence/dishwasher_use.rb
earth-0.0.33 lib/earth/residence/dishwasher_use.rb
earth-0.0.32 lib/earth/residence/dishwasher_use.rb
earth-0.0.31 lib/earth/residence/dishwasher_use.rb
earth-0.0.30 lib/earth/residence/dishwasher_use.rb
earth-0.0.29 lib/earth/residence/dishwasher_use.rb
earth-0.0.28 lib/earth/residence/dishwasher_use.rb
earth-0.0.27 lib/earth/residence/dishwasher_use.rb