lib/earth/air/aircraft_class.rb in earth-0.6.2 vs lib/earth/air/aircraft_class.rb in earth-0.6.3
- old
+ new
@@ -26,14 +26,14 @@
def update_averages!
Aircraft.run_data_miner!
AircraftFuelUseEquation.run_data_miner!
find_each do |aircraft_class|
cumulative_passengers = 0
- aircraft_class.m3 = 0
- aircraft_class.m2 = 0
- aircraft_class.m1 = 0
- aircraft_class.b = 0
+ aircraft_class.m3 = 0.0
+ aircraft_class.m2 = 0.0
+ aircraft_class.m1 = 0.0
+ aircraft_class.b = 0.0
aircraft_class.aircraft.where('passengers > 0 AND fuel_use_code IS NOT NULL').each do |a|
cumulative_passengers += a.passengers
aircraft_class.m3 += a.fuel_use_equation.m3 * a.passengers
aircraft_class.m2 += a.fuel_use_equation.m2 * a.passengers
@@ -48,15 +48,12 @@
aircraft_class.b /= cumulative_passengers
end
aircraft_class.seats = aircraft_class.aircraft.weighted_average(:seats, :weighted_by => :passengers)
- aircraft_class.m3_units = 'kilograms_per_cubic_nautical_mile'
- aircraft_class.m2_units = 'kilograms_per_square_nautical_mile'
- aircraft_class.m1_units = 'kilograms_per_nautical_mile'
- aircraft_class.b_units = 'kilograms'
-
aircraft_class.save!
end
+
+ update_all :m3_units => 'kilograms_per_cubic_nautical_mile', :m2_units => 'kilograms_per_square_nautical_mile', :m1_units => 'kilograms_per_nautical_mile', :b_units => 'kilograms'
end
end
end