lib/earth/automobile/automobile_make/data_miner.rb in earth-0.5.0 vs lib/earth/automobile/automobile_make/data_miner.rb in earth-0.5.2
- old
+ new
@@ -1,19 +1,14 @@
AutomobileMake.class_eval do
data_miner do
process "Start from scratch" do
- connection.drop_table table_name
+ delete_all
end
- schema Earth.database_options do
- string 'name'
- float 'fuel_efficiency'
- string 'fuel_efficiency_units'
- end
-
- process "Ensure AutomobileMakeModelYearVariant is populated" do
+ process "Ensure AutomobileMakeModelYearVariant and AutomobileMakeFleetYear are populated" do
AutomobileMakeModelYearVariant.run_data_miner!
+ AutomobileMakeFleetYear.run_data_miner!
end
process "Derive manufacturer names from automobile make model year variants" do
INSERT_IGNORE %{INTO automobile_makes(name)
SELECT DISTINCT automobile_make_model_year_variants.make_name
@@ -21,23 +16,15 @@
WHERE automobile_make_model_year_variants.make_name IS NOT NULL
AND LENGTH(automobile_make_model_year_variants.make_name) > 0
}
end
- process "Ensure AutomobileMakeFleetYear is populated" do
- AutomobileMakeFleetYear.run_data_miner!
- end
-
# sabshere 1/31/11 add Avanti, DaimlerChrysler, IHC, Tesla, etc.
process "Derive extra manufacturer names from CAFE data" do
INSERT_IGNORE %{INTO automobile_makes(name)
SELECT DISTINCT automobile_make_fleet_years.make_name
FROM automobile_make_fleet_years
}
- end
-
- process "Ensure AutomobileMakeFleetYear is populated" do
- AutomobileMakeFleetYear.run_data_miner!
end
# FIXME TODO make this a method on AutomobileMake?
process "Calculate fuel efficiency from automobile make fleet years for makes with CAFE data" do
make_fleet_years = AutomobileMakeFleetYear.arel_table