flight 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/features/flight_committees.feature +10 -0
- data/lib/flight/carbon_model.rb +15 -1
- metadata +14 -15
@@ -62,6 +62,16 @@ Feature: Flight Committee Calculations
|
|
62
62
|
# airline exists but not in t100
|
63
63
|
# origin not in t100, dest in t100
|
64
64
|
|
65
|
+
Scenario: Cohort committee from segments with no passengers should be nil
|
66
|
+
Given a flight emitter
|
67
|
+
And a characteristic "segments_per_trip" of "1"
|
68
|
+
And a characteristic "origin_airport.iata_code" of "AZP"
|
69
|
+
And a characteristic "destination_airport.iata_code" of "BZP"
|
70
|
+
And a characteristic "aircraft.bp_code" of "6"
|
71
|
+
And a characteristic "airline.iata_code" of "ZA"
|
72
|
+
When the "cohort" committee is calculated
|
73
|
+
Then the conclusion of the committee should be nil
|
74
|
+
|
65
75
|
Scenario: Aircraft class committee from aircraft
|
66
76
|
Given a flight emitter
|
67
77
|
And a characteristic "aircraft.bp_code" of "BP-FM1"
|
data/lib/flight/carbon_model.rb
CHANGED
@@ -269,6 +269,7 @@ module BrighterPlanet
|
|
269
269
|
passengers = flight_segments.inject(0) do |passengers, flight_segment|
|
270
270
|
passengers + flight_segment.passengers
|
271
271
|
end
|
272
|
+
puts "passengers: #{passengers.inspect}"
|
272
273
|
|
273
274
|
bts_codes = flight_segments.map(&:aircraft_bts_code).uniq
|
274
275
|
relevant_aircraft = Aircraft.find_all_by_bts_code(bts_codes).inject({}) do |hsh, aircraft|
|
@@ -280,14 +281,27 @@ module BrighterPlanet
|
|
280
281
|
flight_segments.inject(0) do |coefficient, flight_segment|
|
281
282
|
bts_code = flight_segment.aircraft_bts_code.to_s
|
282
283
|
aircraft = relevant_aircraft[bts_code]
|
284
|
+
if aircraft.nil?
|
285
|
+
puts "aircraft is nil, bts_code is #{bts_code}"
|
286
|
+
puts "flight segment: #{flight_segment.inspect}"
|
287
|
+
end
|
283
288
|
aircraft_coefficient = aircraft.send(name)
|
289
|
+
if aircraft.aircraft_class.nil?
|
290
|
+
puts "aircraft #{aircraft.inspect} has nil class"
|
291
|
+
puts "flight segment: #{flight_segment.inspect}"
|
292
|
+
end
|
284
293
|
if aircraft_coefficient.nil?
|
285
294
|
aircraft_coefficient = aircraft.aircraft_class.send(name)
|
286
295
|
end
|
296
|
+
# puts "coeff = #{coefficient} + (#{aircraft_coefficient} * #{flight_segment.passengers}) = #{coefficient + (aircraft_coefficient * flight_segment.passengers)}"
|
287
297
|
coefficient + (aircraft_coefficient * flight_segment.passengers)
|
288
298
|
end
|
289
299
|
end
|
290
300
|
|
301
|
+
puts "m3 coeff = #{sum_coefficients.call(:m3).inspect}"
|
302
|
+
puts "m2 coeff = #{sum_coefficients.call(:m2).inspect}"
|
303
|
+
puts "m1 coeff = #{sum_coefficients.call(:m1).inspect}"
|
304
|
+
puts "endpoint_fuel coeff = #{sum_coefficients.call(:endpoint_fuel).inspect}"
|
291
305
|
m3 = sum_coefficients.call(:m3) / passengers
|
292
306
|
m2 = sum_coefficients.call(:m2) / passengers
|
293
307
|
m1 = sum_coefficients.call(:m1) / passengers
|
@@ -535,7 +549,7 @@ module BrighterPlanet
|
|
535
549
|
end
|
536
550
|
cohort = FlightSegment.strict_cohort provided_characteristics
|
537
551
|
end
|
538
|
-
if cohort.any?
|
552
|
+
if cohort.any? && !cohort.all? { |fs| fs.passengers.zero? }
|
539
553
|
cohort
|
540
554
|
else
|
541
555
|
nil
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 11
|
9
|
+
version: 0.1.11
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Andy Rossmeissl
|
@@ -18,11 +18,12 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2011-01-
|
21
|
+
date: 2011-01-10 00:00:00 -05:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
25
|
name: activerecord
|
26
|
+
prerelease: false
|
26
27
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
28
|
none: false
|
28
29
|
requirements:
|
@@ -32,10 +33,10 @@ dependencies:
|
|
32
33
|
- 3
|
33
34
|
version: "3"
|
34
35
|
type: :development
|
35
|
-
prerelease: false
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
+
prerelease: false
|
39
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
41
|
none: false
|
41
42
|
requirements:
|
@@ -47,10 +48,10 @@ dependencies:
|
|
47
48
|
- 0
|
48
49
|
version: 1.0.0
|
49
50
|
type: :development
|
50
|
-
prerelease: false
|
51
51
|
version_requirements: *id002
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
53
|
name: cucumber
|
54
|
+
prerelease: false
|
54
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
56
|
none: false
|
56
57
|
requirements:
|
@@ -60,10 +61,10 @@ dependencies:
|
|
60
61
|
- 0
|
61
62
|
version: "0"
|
62
63
|
type: :development
|
63
|
-
prerelease: false
|
64
64
|
version_requirements: *id003
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
66
|
name: jeweler
|
67
|
+
prerelease: false
|
67
68
|
requirement: &id004 !ruby/object:Gem::Requirement
|
68
69
|
none: false
|
69
70
|
requirements:
|
@@ -75,10 +76,10 @@ dependencies:
|
|
75
76
|
- 0
|
76
77
|
version: 1.4.0
|
77
78
|
type: :development
|
78
|
-
prerelease: false
|
79
79
|
version_requirements: *id004
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rake
|
82
|
+
prerelease: false
|
82
83
|
requirement: &id005 !ruby/object:Gem::Requirement
|
83
84
|
none: false
|
84
85
|
requirements:
|
@@ -88,10 +89,10 @@ dependencies:
|
|
88
89
|
- 0
|
89
90
|
version: "0"
|
90
91
|
type: :development
|
91
|
-
prerelease: false
|
92
92
|
version_requirements: *id005
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: rdoc
|
95
|
+
prerelease: false
|
95
96
|
requirement: &id006 !ruby/object:Gem::Requirement
|
96
97
|
none: false
|
97
98
|
requirements:
|
@@ -101,10 +102,10 @@ dependencies:
|
|
101
102
|
- 0
|
102
103
|
version: "0"
|
103
104
|
type: :development
|
104
|
-
prerelease: false
|
105
105
|
version_requirements: *id006
|
106
106
|
- !ruby/object:Gem::Dependency
|
107
107
|
name: rspec
|
108
|
+
prerelease: false
|
108
109
|
requirement: &id007 !ruby/object:Gem::Requirement
|
109
110
|
none: false
|
110
111
|
requirements:
|
@@ -116,10 +117,10 @@ dependencies:
|
|
116
117
|
- 1
|
117
118
|
version: 2.0.1
|
118
119
|
type: :development
|
119
|
-
prerelease: false
|
120
120
|
version_requirements: *id007
|
121
121
|
- !ruby/object:Gem::Dependency
|
122
122
|
name: sniff
|
123
|
+
prerelease: false
|
123
124
|
requirement: &id008 !ruby/object:Gem::Requirement
|
124
125
|
none: false
|
125
126
|
requirements:
|
@@ -131,10 +132,10 @@ dependencies:
|
|
131
132
|
- 12
|
132
133
|
version: 0.4.12
|
133
134
|
type: :development
|
134
|
-
prerelease: false
|
135
135
|
version_requirements: *id008
|
136
136
|
- !ruby/object:Gem::Dependency
|
137
137
|
name: emitter
|
138
|
+
prerelease: false
|
138
139
|
requirement: &id009 !ruby/object:Gem::Requirement
|
139
140
|
none: false
|
140
141
|
requirements:
|
@@ -145,10 +146,10 @@ dependencies:
|
|
145
146
|
- 3
|
146
147
|
version: "0.3"
|
147
148
|
type: :runtime
|
148
|
-
prerelease: false
|
149
149
|
version_requirements: *id009
|
150
150
|
- !ruby/object:Gem::Dependency
|
151
151
|
name: earth
|
152
|
+
prerelease: false
|
152
153
|
requirement: &id010 !ruby/object:Gem::Requirement
|
153
154
|
none: false
|
154
155
|
requirements:
|
@@ -159,10 +160,10 @@ dependencies:
|
|
159
160
|
- 3
|
160
161
|
version: "0.3"
|
161
162
|
type: :runtime
|
162
|
-
prerelease: false
|
163
163
|
version_requirements: *id010
|
164
164
|
- !ruby/object:Gem::Dependency
|
165
165
|
name: builder
|
166
|
+
prerelease: false
|
166
167
|
requirement: &id011 !ruby/object:Gem::Requirement
|
167
168
|
none: false
|
168
169
|
requirements:
|
@@ -172,7 +173,6 @@ dependencies:
|
|
172
173
|
- 0
|
173
174
|
version: "0"
|
174
175
|
type: :runtime
|
175
|
-
prerelease: false
|
176
176
|
version_requirements: *id011
|
177
177
|
description: A software model in Ruby for the greenhouse gas emissions of a flight
|
178
178
|
email: andy@rossmeissl.net
|
@@ -216,7 +216,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
216
|
requirements:
|
217
217
|
- - ">="
|
218
218
|
- !ruby/object:Gem::Version
|
219
|
-
hash: 805356979
|
220
219
|
segments:
|
221
220
|
- 0
|
222
221
|
version: "0"
|