Sha256: 83f9024d7ae29f0f620689ade55eed12b7626e6e2f1ddc404165927d644b1675

Contents?: true

Size: 813 Bytes

Versions: 1

Compression:

Stored size: 813 Bytes

Contents

FlightSeatClass.class_eval do
  data_miner do
    process "Ensure that FlightDistanceClassSeatClass is populated" do
      FlightDistanceClassSeatClass.run_data_miner!
    end
    
    process "Derive flight seat classes names from FlightDistanceClassSeatClass" do
      connection.select_values("SELECT DISTINCT seat_class_name FROM #{FlightDistanceClassSeatClass.quoted_table_name}").each do |seat_class_name|
        find_or_create_by_name seat_class_name
      end
    end
    
    process "Calculate multipliers from FlightDistanceClassSeatClass and FlightDistanceClass" do
      find_each do |seat_class|
        seat_class.multiplier = seat_class.distance_class_seat_classes.weighted_average(:multiplier, :weighted_by => [:distance_class, :passengers])
        seat_class.save!
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
earth-0.7.0 lib/earth/air/flight_seat_class/data_miner.rb