earth 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +2 -2
- data/LICENSE-PREAMBLE +54 -0
- data/features/automobile_make_model_year.feature +4 -4
- data/features/automobile_make_model_year_variant.feature +4 -4
- data/features/automobile_make_year.feature +4 -14
- data/features/support/imports/automobile_make_model_year_bad.csv +1 -1
- data/features/support/imports/automobile_make_model_year_good.csv +1 -1
- data/features/support/imports/automobile_make_model_year_variant_bad.csv +3 -3
- data/features/support/imports/automobile_make_model_year_variant_good.csv +3 -3
- data/features/support/imports/automobile_make_year_bad.csv +3 -3
- data/features/support/imports/automobile_make_year_good.csv +3 -3
- data/lib/earth/automobile/automobile_make.rb +0 -2
- data/lib/earth/automobile/automobile_make/data_miner.rb +19 -12
- data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +4 -11
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +15 -7
- data/lib/earth/automobile/automobile_make_year/data_miner.rb +26 -21
- metadata +6 -4
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
earth (0.3.
|
|
4
|
+
earth (0.3.10)
|
|
5
5
|
activerecord (~> 3)
|
|
6
6
|
cohort_scope (>= 0.0.7)
|
|
7
7
|
conversions (>= 1.4.5)
|
|
@@ -176,5 +176,5 @@ DEPENDENCIES
|
|
|
176
176
|
falls_back_on (>= 0.0.3)
|
|
177
177
|
geokit (>= 1.5.0)
|
|
178
178
|
loose_tight_dictionary (>= 0.0.8)
|
|
179
|
-
sniff (~> 0.4.
|
|
179
|
+
sniff (~> 0.4.11)
|
|
180
180
|
weighted_average (>= 0.0.4)
|
data/LICENSE-PREAMBLE
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
BRIGHTER PLANET ADDITIONAL PREAMBLE TO THE GNU AFFERO GENERAL PUBLIC LICENSE
|
|
2
|
+
January 7, 2011
|
|
3
|
+
|
|
4
|
+
This preamble is meant to help the licensee understand exactly what
|
|
5
|
+
software is being received under the license and set expectations as to
|
|
6
|
+
what is not covered.
|
|
7
|
+
|
|
8
|
+
IDENTITY OF THE SOFTWARE MODULE COVERED BY LICENSE:
|
|
9
|
+
|
|
10
|
+
This license covers the Brighter Planet reference data import module,
|
|
11
|
+
referred to as 'earth,' officially distributed from
|
|
12
|
+
http://github.com/brighterplanet/earth.
|
|
13
|
+
|
|
14
|
+
SCOPE OF THE SOFTWARE MODULE COVERED BY LICENSE:
|
|
15
|
+
|
|
16
|
+
The scope of the license includes only those files included in the
|
|
17
|
+
official Brighter Planet distribution package for the reference data
|
|
18
|
+
import module, including only the reference data import scripts.
|
|
19
|
+
|
|
20
|
+
WHAT IS NOT COVERED BY LICENSE:
|
|
21
|
+
|
|
22
|
+
This license does not extend to the following:
|
|
23
|
+
|
|
24
|
+
* Any element of any Brighter Planet website, including but not
|
|
25
|
+
limited the copyrights, trademarks, graphic design, text,
|
|
26
|
+
documentation, method of interaction with clients, runtime
|
|
27
|
+
environment, technical infrastructure, and software code associated
|
|
28
|
+
therewith;
|
|
29
|
+
|
|
30
|
+
* Any element of any Brighter Planet website user interface, including
|
|
31
|
+
but not limited to the copyrights, trademarks, graphic design, text,
|
|
32
|
+
documentation, method of interaction with clients, runtime
|
|
33
|
+
environment, technical infrastructure, and software code associated
|
|
34
|
+
therewith;
|
|
35
|
+
|
|
36
|
+
* Any element of other software modules licensed under any form of
|
|
37
|
+
license including but not limited to other forms of open source
|
|
38
|
+
license, commercial license, and the like;
|
|
39
|
+
|
|
40
|
+
* Any element of any Brighter Planet Carbon Middleware web service,
|
|
41
|
+
including but not limited to the copyrights, trademarks, graphic
|
|
42
|
+
design, text, documentation, method of interaction with clients,
|
|
43
|
+
runtime environment, technical infrastructure, and software code, is
|
|
44
|
+
not covered by the license; and
|
|
45
|
+
|
|
46
|
+
* Any aspect or use of http://data.brighterplanet.com.
|
|
47
|
+
|
|
48
|
+
* Any use of the imported data that would infringe on the rights of
|
|
49
|
+
the original copyright holder of the imported data, such as resale
|
|
50
|
+
for profit.
|
|
51
|
+
|
|
52
|
+
If you have any questions, please contact licensing@brighterplanet.com
|
|
53
|
+
|
|
54
|
+
Copyright 2010, 2011 Brighter Planet, Inc.
|
|
@@ -3,9 +3,9 @@ Feature: Data import for AutomobileMakeModelYear
|
|
|
3
3
|
I want to import MakeModelYear data
|
|
4
4
|
So that I can perform model year-based calculations
|
|
5
5
|
|
|
6
|
-
Scenario: Successfully verifying that year is between 1985 and
|
|
6
|
+
Scenario: Successfully verifying that year is between 1985 and 2010
|
|
7
7
|
Given a "AutomobileMakeModelYear" data import fetches results listed in "automobile_make_model_year_good"
|
|
8
|
-
When a data import verifies "Year should be between 1985 and
|
|
8
|
+
When a data import verifies "Year should be between 1985 and 2010"
|
|
9
9
|
Then the verification should be successful
|
|
10
10
|
|
|
11
11
|
Scenario: Successfully verifying that fuel efficiences are greater than zero
|
|
@@ -18,9 +18,9 @@ Feature: Data import for AutomobileMakeModelYear
|
|
|
18
18
|
When a data import verifies "Fuel efficiency units should be kilometres per litre"
|
|
19
19
|
Then the verification should be successful
|
|
20
20
|
|
|
21
|
-
Scenario: Failing to verify that year is between 1985 and
|
|
21
|
+
Scenario: Failing to verify that year is between 1985 and 2010
|
|
22
22
|
Given a "AutomobileMakeModelYear" data import fetches results listed in "automobile_make_model_year_bad"
|
|
23
|
-
When a data import verifies "Year should be between 1985 and
|
|
23
|
+
When a data import verifies "Year should be between 1985 and 2010"
|
|
24
24
|
Then the verification should not be successful
|
|
25
25
|
|
|
26
26
|
Scenario: Failing to verify that fuel efficiences are greater than zero
|
|
@@ -3,9 +3,9 @@ Feature: Data import for AutomobileMakeModelYearVariant
|
|
|
3
3
|
I want to import MakeModelYearVariant data
|
|
4
4
|
So that I can perform variant-based calculations
|
|
5
5
|
|
|
6
|
-
Scenario: Successfully verifying that year is between 1985 and
|
|
6
|
+
Scenario: Successfully verifying that year is between 1985 and 2010
|
|
7
7
|
Given a "AutomobileMakeModelYearVariant" data import fetches results listed in "automobile_make_model_year_variant_good"
|
|
8
|
-
When a data import verifies "Year should be between 1985 and
|
|
8
|
+
When a data import verifies "Year should be between 1985 and 2010"
|
|
9
9
|
Then the verification should be successful
|
|
10
10
|
|
|
11
11
|
# FIXME TODO
|
|
@@ -24,9 +24,9 @@ Feature: Data import for AutomobileMakeModelYearVariant
|
|
|
24
24
|
When a data import verifies "Fuel efficiency units should be kilometres per litre"
|
|
25
25
|
Then the verification should be successful
|
|
26
26
|
|
|
27
|
-
Scenario: Failing to verify that year is between 1985 and
|
|
27
|
+
Scenario: Failing to verify that year is between 1985 and 2010
|
|
28
28
|
Given a "AutomobileMakeModelYearVariant" data import fetches results listed in "automobile_make_model_year_variant_bad"
|
|
29
|
-
When a data import verifies "Year should be between 1985 and
|
|
29
|
+
When a data import verifies "Year should be between 1985 and 2010"
|
|
30
30
|
Then the verification should not be successful
|
|
31
31
|
|
|
32
32
|
# FIXME TODO
|
|
@@ -3,9 +3,9 @@ Feature: Data import for AutomobileMakeYear
|
|
|
3
3
|
I want to import MakeYear data
|
|
4
4
|
So that I can perform year-based calculations
|
|
5
5
|
|
|
6
|
-
Scenario: Successfully verifying that year is between
|
|
6
|
+
Scenario: Successfully verifying that year is between 1985 and 2010
|
|
7
7
|
Given a "AutomobileMakeYear" data import fetches results listed in "automobile_make_year_good"
|
|
8
|
-
When a data import verifies "Year should be between
|
|
8
|
+
When a data import verifies "Year should be between 1985 and 2010"
|
|
9
9
|
Then the verification should be successful
|
|
10
10
|
|
|
11
11
|
Scenario: Successfully verifying that fuel efficiency is greater than zero
|
|
@@ -13,19 +13,14 @@ Feature: Data import for AutomobileMakeYear
|
|
|
13
13
|
When a data import verifies "Fuel efficiency should be greater than zero"
|
|
14
14
|
Then the verification should be successful
|
|
15
15
|
|
|
16
|
-
Scenario: Successfully verifying that volume is greater than zero
|
|
17
|
-
Given a "AutomobileMakeYear" data import fetches results listed in "automobile_make_year_good"
|
|
18
|
-
When a data import verifies "Volume should be greater than zero"
|
|
19
|
-
Then the verification should be successful
|
|
20
|
-
|
|
21
16
|
Scenario: Successfully verifying that fuel efficiency units are kilometres per litre
|
|
22
17
|
Given a "AutomobileMakeYear" data import fetches results listed in "automobile_make_year_good"
|
|
23
18
|
When a data import verifies "Fuel efficiency units should be kilometres per litre"
|
|
24
19
|
Then the verification should be successful
|
|
25
20
|
|
|
26
|
-
Scenario: Failing to verify that year is between
|
|
21
|
+
Scenario: Failing to verify that year is between 1985 and 2010
|
|
27
22
|
Given a "AutomobileMakeYear" data import fetches results listed in "automobile_make_year_bad"
|
|
28
|
-
When a data import verifies "Year should be between
|
|
23
|
+
When a data import verifies "Year should be between 1985 and 2010"
|
|
29
24
|
Then the verification should not be successful
|
|
30
25
|
|
|
31
26
|
Scenario: Failing to verify that fuel efficiency is greater than zero
|
|
@@ -33,11 +28,6 @@ Feature: Data import for AutomobileMakeYear
|
|
|
33
28
|
When a data import verifies "Fuel efficiency should be greater than zero"
|
|
34
29
|
Then the verification should not be successful
|
|
35
30
|
|
|
36
|
-
Scenario: Failing to verify that volume is greater than zero
|
|
37
|
-
Given a "AutomobileMakeYear" data import fetches results listed in "automobile_make_year_bad"
|
|
38
|
-
When a data import verifies "Volume should be greater than zero"
|
|
39
|
-
Then the verification should not be successful
|
|
40
|
-
|
|
41
31
|
Scenario: Failing to verify that fuel efficiency units are kilometres per litre
|
|
42
32
|
Given a "AutomobileMakeYear" data import fetches results listed in "automobile_make_year_bad"
|
|
43
33
|
When a data import verifies "Fuel efficiency units should be kilometres per litre"
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
name,year,fuel_efficiency_city,fuel_efficiency_highway,fuel_efficiency_city_units,fuel_efficiency_highway_units
|
|
2
2
|
Toyota,2000,10,10.5,kilometres_per_litre,kilometres_per_litre
|
|
3
|
-
Honda,
|
|
3
|
+
Honda,2010,20,21,kilometres_per_litre,kilometres_per_litre
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
row_hash,year,fuel_type_code,fuel_efficiency_city,fuel_efficiency_highway,fuel_efficiency_city_units,fuel_efficiency_highway_units
|
|
2
|
-
a1,2000,D,10.0,15.0,kilometres_per_litre,kilometres_per_litre
|
|
3
|
-
b2,
|
|
1
|
+
row_hash,year,fuel_type_code,fuel_efficiency,fuel_efficiency_city,fuel_efficiency_highway,fuel_efficiency_units,fuel_efficiency_city_units,fuel_efficiency_highway_units
|
|
2
|
+
a1,2000,D,12.0,10.0,15.0,kilometres_per_litre,kilometres_per_litre,kilometres_per_litre
|
|
3
|
+
b2,2011,P,0,-10,0,foo,bar
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
row_hash,year,fuel_type_code,fuel_efficiency_city,fuel_efficiency_highway,fuel_efficiency_city_units,fuel_efficiency_highway_units
|
|
2
|
-
a1,2000,D,10.0,15.0,kilometres_per_litre,kilometres_per_litre
|
|
3
|
-
b2,
|
|
1
|
+
row_hash,year,fuel_type_code,fuel_efficiency,fuel_efficiency_city,fuel_efficiency_highway,fuel_efficiency_units,fuel_efficiency_city_units,fuel_efficiency_highway_units
|
|
2
|
+
a1,2000,D,12.0,10.0,15.0,kilometres_per_litre,kilometres_per_litre,kilometres_per_litre
|
|
3
|
+
b2,2010,X,20.5,20.0,21.0,kilometres_per_litre,kilometres_per_litre,kilometres_per_litre
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
name,year,fuel_efficiency,volume
|
|
2
|
-
Toyota 2000,2000,10,1000
|
|
3
|
-
Honda
|
|
1
|
+
name,year,fuel_efficiency,fuel_efficiency_units,volume
|
|
2
|
+
Toyota 2000,2000,10,kilometres_per_litre,1000
|
|
3
|
+
Honda 2011,2011,-10,foo,2000
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
name,year,fuel_efficiency,volume
|
|
2
|
-
Toyota 2000,2000,10,1000
|
|
3
|
-
Honda
|
|
1
|
+
name,year,fuel_efficiency,fuel_efficiency_units,volume
|
|
2
|
+
Toyota 2000,2000,10,kilometres_per_litre,1000
|
|
3
|
+
Honda 2010,2010,15,kilometres_per_litre
|
|
@@ -6,8 +6,6 @@ class AutomobileMake < ActiveRecord::Base
|
|
|
6
6
|
has_many :fleet_years, :class_name => 'AutomobileMakeFleetYear', :foreign_key => 'make_name'
|
|
7
7
|
has_many :make_model_year_variants, :class_name => 'AutomobileMakeModelYearVariant', :foreign_key => 'make_name'
|
|
8
8
|
|
|
9
|
-
scope :major, :conditions => { :major => true }, :order => :name
|
|
10
|
-
|
|
11
9
|
data_miner do
|
|
12
10
|
tap "Brighter Planet's make year data", Earth.taps_server
|
|
13
11
|
end
|
|
@@ -6,26 +6,20 @@ AutomobileMake.class_eval do
|
|
|
6
6
|
|
|
7
7
|
schema Earth.database_options do
|
|
8
8
|
string 'name'
|
|
9
|
-
boolean 'major'
|
|
10
9
|
float 'fuel_efficiency'
|
|
11
10
|
string 'fuel_efficiency_units'
|
|
12
11
|
end
|
|
13
|
-
|
|
14
|
-
process "Derive manufacturer names from automobile make
|
|
15
|
-
|
|
12
|
+
|
|
13
|
+
process "Derive manufacturer names from automobile make model year variants" do
|
|
14
|
+
AutomobileMakeModelYearVariant.run_data_miner!
|
|
16
15
|
connection.execute %{
|
|
17
16
|
INSERT IGNORE INTO automobile_makes(name)
|
|
18
|
-
SELECT DISTINCT
|
|
17
|
+
SELECT DISTINCT automobile_make_model_year_variants.make_name
|
|
18
|
+
FROM automobile_make_model_year_variants
|
|
19
19
|
}
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
:url => 'http://static.brighterplanet.com/science/data/transport/automobiles/makes/make_importance.csv' do
|
|
24
|
-
key 'name'
|
|
25
|
-
store 'major'
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
process "Derive average fuel efficiency from automobile make fleet years" do
|
|
22
|
+
process "Calculate fuel efficiency from automobile make fleet years for makes with CAFE data" do
|
|
29
23
|
AutomobileMakeFleetYear.run_data_miner!
|
|
30
24
|
make_fleet_years = AutomobileMakeFleetYear.arel_table
|
|
31
25
|
makes = AutomobileMake.arel_table
|
|
@@ -35,6 +29,19 @@ AutomobileMake.class_eval do
|
|
|
35
29
|
update_all "fuel_efficiency_units = 'kilometres_per_litre'"
|
|
36
30
|
end
|
|
37
31
|
|
|
32
|
+
process "Calculate fuel effeciency from automobile make model year variants for makes without CAFE data" do
|
|
33
|
+
connection.execute %{
|
|
34
|
+
UPDATE automobile_makes
|
|
35
|
+
SET automobile_makes.fuel_efficiency = (SELECT AVG(automobile_make_model_year_variants.fuel_efficiency) FROM automobile_make_model_year_variants WHERE automobile_makes.name = automobile_make_model_year_variants.make_name)
|
|
36
|
+
WHERE automobile_makes.fuel_efficiency IS NULL
|
|
37
|
+
}
|
|
38
|
+
connection.execute %{
|
|
39
|
+
UPDATE automobile_makes
|
|
40
|
+
SET automobile_makes.fuel_efficiency_units = 'kilometres_per_litre'
|
|
41
|
+
WHERE automobile_makes.fuel_efficiency_units IS NULL
|
|
42
|
+
}
|
|
43
|
+
end
|
|
44
|
+
|
|
38
45
|
verify "Fuel efficiency should be greater than zero" do
|
|
39
46
|
AutomobileMake.all.each do |make|
|
|
40
47
|
unless make.fuel_efficiency > 0
|
|
@@ -10,8 +10,6 @@ AutomobileMakeModelYear.class_eval do
|
|
|
10
10
|
string 'make_model_name'
|
|
11
11
|
integer 'year'
|
|
12
12
|
string 'make_year_name'
|
|
13
|
-
float 'fuel_efficiency'
|
|
14
|
-
string 'fuel_efficiency_units'
|
|
15
13
|
float 'fuel_efficiency_city'
|
|
16
14
|
string 'fuel_efficiency_city_units'
|
|
17
15
|
float 'fuel_efficiency_highway'
|
|
@@ -44,15 +42,10 @@ AutomobileMakeModelYear.class_eval do
|
|
|
44
42
|
end
|
|
45
43
|
end
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
update_all "fuel_efficiency = 1 / ((0.43 / fuel_efficiency_city) + (0.57 / fuel_efficiency_highway))"
|
|
49
|
-
update_all "fuel_efficiency_units = 'kilometres_per_litre'"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
verify "Year should be between 1985 and 2009" do
|
|
45
|
+
verify "Year should be between 1985 and 2010" do
|
|
53
46
|
AutomobileMakeModelYear.all.each do |model_year|
|
|
54
|
-
unless model_year.year > 1984 and model_year.year <
|
|
55
|
-
raise "Invalid year for AutomobileMakeModelYear #{model_year.name}: #{model_year.year} (should be between 1985 and
|
|
47
|
+
unless model_year.year.to_i > 1984 and model_year.year.to_i < 2011
|
|
48
|
+
raise "Invalid year for AutomobileMakeModelYear #{model_year.name}: #{model_year.year} (should be between 1985 and 2010)"
|
|
56
49
|
end
|
|
57
50
|
end
|
|
58
51
|
end
|
|
@@ -61,7 +54,7 @@ AutomobileMakeModelYear.class_eval do
|
|
|
61
54
|
AutomobileMakeModelYear.all.each do |model_year|
|
|
62
55
|
%w{ city highway }.each do |type|
|
|
63
56
|
fuel_efficiency = model_year.send(:"fuel_efficiency_#{type}")
|
|
64
|
-
unless fuel_efficiency > 0
|
|
57
|
+
unless fuel_efficiency.to_f > 0
|
|
65
58
|
raise "Invalid fuel efficiency #{type} for AutomobileMakeModelYear #{model_year.name}: #{fuel_efficiency} (should be > 0)"
|
|
66
59
|
end
|
|
67
60
|
end
|
|
@@ -283,6 +283,8 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
|
283
283
|
string 'make_year_name' # make + year
|
|
284
284
|
string 'make_model_year_name' # make + model + year
|
|
285
285
|
integer 'year'
|
|
286
|
+
float 'fuel_efficiency'
|
|
287
|
+
string 'fuel_efficiency_units'
|
|
286
288
|
float 'fuel_efficiency_city'
|
|
287
289
|
string 'fuel_efficiency_city_units'
|
|
288
290
|
float 'fuel_efficiency_highway'
|
|
@@ -451,16 +453,22 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
|
451
453
|
update_all 'fuel_efficiency_highway = 1 / ((0.001376 / 0.425143707) + (1.3466 / raw_fuel_efficiency_highway))'
|
|
452
454
|
end
|
|
453
455
|
|
|
456
|
+
# This will be useful later for calculating MakeModel and Make fuel efficiency based on Variant
|
|
457
|
+
process "Calculate combined adjusted fuel efficiency using the latest EPA equation" do
|
|
458
|
+
update_all "fuel_efficiency = 1 / ((0.43 / fuel_efficiency_city) + (0.57 / fuel_efficiency_highway))"
|
|
459
|
+
update_all "fuel_efficiency_units = 'kilometres_per_litre'"
|
|
460
|
+
end
|
|
461
|
+
|
|
454
462
|
%w{ AutomobileMakeModelYear AutomobileMakeModel }.each do |synthetic_resource|
|
|
455
463
|
process "Synthesize #{synthetic_resource}" do
|
|
456
464
|
synthetic_resource.constantize.run_data_miner!
|
|
457
465
|
end
|
|
458
466
|
end
|
|
459
467
|
|
|
460
|
-
verify "Year should be between 1985 and
|
|
468
|
+
verify "Year should be between 1985 and 2010" do
|
|
461
469
|
AutomobileMakeModelYearVariant.all.each do |variant|
|
|
462
|
-
unless variant.year > 1984 and variant.year <
|
|
463
|
-
raise "Invalid year for AutomobileMakeModelYearVariant #{variant.row_hash}: #{variant.year} (should be between 1985 and
|
|
470
|
+
unless variant.year > 1984 and variant.year < 2011
|
|
471
|
+
raise "Invalid year for AutomobileMakeModelYearVariant #{variant.row_hash}: #{variant.year} (should be between 1985 and 2010)"
|
|
464
472
|
end
|
|
465
473
|
end
|
|
466
474
|
end
|
|
@@ -478,8 +486,8 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
|
478
486
|
#
|
|
479
487
|
verify "Fuel efficiencies should be greater than zero" do
|
|
480
488
|
AutomobileMakeModelYearVariant.all.each do |variant|
|
|
481
|
-
|
|
482
|
-
fuel_efficiency = variant.send(
|
|
489
|
+
[:fuel_efficiency, :fuel_efficiency_city, :fuel_efficiency_highway].each do |type|
|
|
490
|
+
fuel_efficiency = variant.send(type)
|
|
483
491
|
unless fuel_efficiency > 0
|
|
484
492
|
raise "Invalid fuel efficiency #{type} for AutomobileMakeModelYearVariant #{variant.row_hash}: #{fuel_efficiency} (should be < 0)"
|
|
485
493
|
end
|
|
@@ -489,8 +497,8 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
|
489
497
|
|
|
490
498
|
verify "Fuel efficiency units should be kilometres per litre" do
|
|
491
499
|
AutomobileMakeModelYearVariant.all.each do |variant|
|
|
492
|
-
|
|
493
|
-
units = variant.send(
|
|
500
|
+
[:fuel_efficiency_units, :fuel_efficiency_city_units, :fuel_efficiency_highway_units].each do |type|
|
|
501
|
+
units = variant.send(type)
|
|
494
502
|
unless units == "kilometres_per_litre"
|
|
495
503
|
raise "Invalid fuel efficiency #{type} units for AutomobileMakeModelYearVariant #{variant.row_hash}: #{units} (should be kilometres_per_litre)"
|
|
496
504
|
end
|
|
@@ -10,22 +10,22 @@ AutomobileMakeYear.class_eval do
|
|
|
10
10
|
integer 'year'
|
|
11
11
|
float 'fuel_efficiency'
|
|
12
12
|
string 'fuel_efficiency_units'
|
|
13
|
-
integer 'volume'
|
|
13
|
+
integer 'volume' # This will sometimes be null because not all make_years have CAFE data
|
|
14
14
|
end
|
|
15
|
-
|
|
16
|
-
process "Derive manufacturer names and years from automobile make
|
|
17
|
-
|
|
15
|
+
|
|
16
|
+
process "Derive manufacturer names and years from automobile make model year variants" do
|
|
17
|
+
AutomobileMakeModelYearVariant.run_data_miner!
|
|
18
18
|
connection.execute %{
|
|
19
19
|
INSERT IGNORE INTO automobile_make_years(name, make_name, year)
|
|
20
20
|
SELECT
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
FROM
|
|
21
|
+
automobile_make_model_year_variants.make_year_name,
|
|
22
|
+
automobile_make_model_year_variants.make_name,
|
|
23
|
+
automobile_make_model_year_variants.year
|
|
24
|
+
FROM automobile_make_model_year_variants
|
|
25
25
|
}
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
process "
|
|
28
|
+
process "Calculate fuel efficiency from make fleet years for makes with CAFE data" do
|
|
29
29
|
AutomobileMakeFleetYear.run_data_miner!
|
|
30
30
|
make_fleet_years = AutomobileMakeFleetYear.arel_table
|
|
31
31
|
make_years = AutomobileMakeYear.arel_table
|
|
@@ -35,16 +35,29 @@ AutomobileMakeYear.class_eval do
|
|
|
35
35
|
update_all "fuel_efficiency_units = 'kilometres_per_litre'"
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
process "
|
|
38
|
+
process "Calculate fuel effeciency from automobile make model year variants for makes without CAFE data" do
|
|
39
|
+
connection.execute %{
|
|
40
|
+
UPDATE automobile_make_years
|
|
41
|
+
SET automobile_make_years.fuel_efficiency = (SELECT AVG(automobile_make_model_year_variants.fuel_efficiency) FROM automobile_make_model_year_variants WHERE automobile_make_years.name = automobile_make_model_year_variants.make_year_name)
|
|
42
|
+
WHERE automobile_make_years.fuel_efficiency IS NULL
|
|
43
|
+
}
|
|
44
|
+
connection.execute %{
|
|
45
|
+
UPDATE automobile_make_years
|
|
46
|
+
SET automobile_make_years.fuel_efficiency_units = 'kilometres_per_litre'
|
|
47
|
+
WHERE automobile_make_years.fuel_efficiency_units IS NULL
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
process "Calculate sales volume from automobile make fleet years for makes with CAFE data" do
|
|
39
52
|
connection.execute %{
|
|
40
53
|
UPDATE automobile_make_years SET automobile_make_years.volume = (SELECT SUM(automobile_make_fleet_years.volume) FROM automobile_make_fleet_years WHERE automobile_make_fleet_years.make_year_name = automobile_make_years.name)
|
|
41
54
|
}
|
|
42
55
|
end
|
|
43
56
|
|
|
44
|
-
verify "Year should be between
|
|
57
|
+
verify "Year should be between 1985 and 2010" do
|
|
45
58
|
AutomobileMakeYear.all.each do |make_year|
|
|
46
|
-
unless make_year.year >
|
|
47
|
-
raise "Invalid year for AutomobileMakeYear #{make_year.name}: #{make_year.year} (should be between
|
|
59
|
+
unless make_year.year > 1984 and make_year.year < 2011
|
|
60
|
+
raise "Invalid year for AutomobileMakeYear #{make_year.name}: #{make_year.year} (should be between 1985 and 2010)"
|
|
48
61
|
end
|
|
49
62
|
end
|
|
50
63
|
end
|
|
@@ -64,13 +77,5 @@ AutomobileMakeYear.class_eval do
|
|
|
64
77
|
end
|
|
65
78
|
end
|
|
66
79
|
end
|
|
67
|
-
|
|
68
|
-
verify "Volume should be greater than zero" do
|
|
69
|
-
AutomobileMakeYear.all.each do |make_year|
|
|
70
|
-
unless make_year.volume > 0
|
|
71
|
-
raise "Invalid volume for AutomobileMakeYear #{make_year.name}: #{make_year.volume} (should be > 0)"
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
80
|
end
|
|
76
81
|
end
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 3
|
|
8
|
-
-
|
|
9
|
-
version: 0.3.
|
|
8
|
+
- 11
|
|
9
|
+
version: 0.3.11
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Seamus Abshere
|
|
@@ -16,7 +16,7 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date:
|
|
19
|
+
date: 2011-01-11 00:00:00 -05:00
|
|
20
20
|
default_executable:
|
|
21
21
|
dependencies:
|
|
22
22
|
- !ruby/object:Gem::Dependency
|
|
@@ -160,6 +160,7 @@ extensions: []
|
|
|
160
160
|
|
|
161
161
|
extra_rdoc_files:
|
|
162
162
|
- LICENSE
|
|
163
|
+
- LICENSE-PREAMBLE
|
|
163
164
|
- README.markdown
|
|
164
165
|
files:
|
|
165
166
|
- LICENSE
|
|
@@ -344,6 +345,7 @@ files:
|
|
|
344
345
|
- vendor/geokit-rails/test/schema.rb
|
|
345
346
|
- vendor/geokit-rails/test/tasks.rake
|
|
346
347
|
- vendor/geokit-rails/test/test_helper.rb
|
|
348
|
+
- LICENSE-PREAMBLE
|
|
347
349
|
- features/automobile_make_model_year.feature
|
|
348
350
|
- features/automobile_make_year.feature
|
|
349
351
|
- features/shipment_mode.feature
|
|
@@ -409,7 +411,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
409
411
|
requirements:
|
|
410
412
|
- - ">="
|
|
411
413
|
- !ruby/object:Gem::Version
|
|
412
|
-
hash:
|
|
414
|
+
hash: 1003851629
|
|
413
415
|
segments:
|
|
414
416
|
- 0
|
|
415
417
|
version: "0"
|