flight 0.0.19 → 0.0.20

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.
@@ -66,19 +66,41 @@ module BrighterPlanet
66
66
  passengers + flight_segment.passengers
67
67
  end
68
68
 
69
- m3 = flight_segments.inject(0) do |m3, flight_segment|
70
- aircraft = Aircraft.find_by_bts_aircraft_type_code flight_segment.bts_aircraft_type_code
71
- m3 + (aircraft.m3 * flight_segment.passengers)
69
+ flight_segment_aircraft = flight_segments.inject({}) do |hsh, flight_segment|
70
+ bts_code = flight_segment.bts_aircraft_type_code
71
+ key = flight_segment.row_hash
72
+ hsh[key] = Aircraft.find_by_bts_aircraft_type_code bts_code
73
+ hsh
72
74
  end
73
75
 
74
- m2 = flight_segments.inject(0) do |m2, flight_segment|
75
- aircraft = Aircraft.find_by_bts_aircraft_type_code flight_segment.bts_aircraft_type_code
76
- m2 + (aircraft.m2 * flight_segment.passengers)
76
+ if flight_segment_aircraft.values.map(&:m3).any?
77
+ m3 = flight_segments.inject(0) do |m3, flight_segment|
78
+ aircraft = flight_segment_aircraft[flight_segment.row_hash]
79
+ aircraft_m3 = aircraft.m3 || 0
80
+ m3 + (aircraft_m3 * flight_segment.passengers)
81
+ end
82
+ else
83
+ m3 = Aircraft.fallback.m3
84
+ end
85
+
86
+ if flight_segment_aircraft.values.map(&:m2).any?
87
+ m2 = flight_segments.inject(0) do |m2, flight_segment|
88
+ aircraft = Aircraft.find_by_bts_aircraft_type_code flight_segment.bts_aircraft_type_code
89
+ aircraft_m2 = aircraft.m2 || 0
90
+ m2 + (aircraft_m2 * flight_segment.passengers)
91
+ end
92
+ else
93
+ m2 = Aircraft.fallback.m2
77
94
  end
78
95
 
79
- m1 = flight_segments.inject(0) do |m1, flight_segment|
80
- aircraft = Aircraft.find_by_bts_aircraft_type_code flight_segment.bts_aircraft_type_code
81
- m1 + (aircraft.m1 * flight_segment.passengers)
96
+ if flight_segment_aircraft.values.map(&:m1).any?
97
+ m1 = flight_segments.inject(0) do |m1, flight_segment|
98
+ aircraft = Aircraft.find_by_bts_aircraft_type_code flight_segment.bts_aircraft_type_code
99
+ aircraft_m1 = aircraft.m1 || 0
100
+ m1 + (aircraft_m1 * flight_segment.passengers)
101
+ end
102
+ else
103
+ m1 = Aircraft.fallback.m1
82
104
  end
83
105
 
84
106
  endpoint_fuel = flight_segments.inject(0) do |endpoint_fuel, flight_segment|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flight
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 55
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 19
10
- version: 0.0.19
9
+ - 20
10
+ version: 0.0.20
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andy Rossmeissl
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2010-09-22 00:00:00 -04:00
22
+ date: 2010-09-23 00:00:00 -04:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
@@ -141,12 +141,12 @@ dependencies:
141
141
  requirements:
142
142
  - - ~>
143
143
  - !ruby/object:Gem::Version
144
- hash: 7
144
+ hash: 23
145
145
  segments:
146
146
  - 0
147
- - 1
148
- - 14
149
- version: 0.1.14
147
+ - 2
148
+ - 0
149
+ version: 0.2.0
150
150
  requirement: *id008
151
151
  - !ruby/object:Gem::Dependency
152
152
  type: :runtime
@@ -182,7 +182,6 @@ files:
182
182
  - lib/flight/characterization.rb
183
183
  - lib/flight/data.rb
184
184
  - lib/flight/summarization.rb
185
- - lib/test_support/db/schema.rb
186
185
  - lib/test_support/flight_record.rb
187
186
  - README.markdown
188
187
  - features/support/env.rb
@@ -226,5 +225,4 @@ test_files:
226
225
  - features/support/env.rb
227
226
  - features/flight_committees.feature
228
227
  - features/flight_emissions.feature
229
- - lib/test_support/db/schema.rb
230
228
  - lib/test_support/flight_record.rb
@@ -1,26 +0,0 @@
1
- require 'sniff/database'
2
-
3
- Sniff::Database.define_schema do
4
- create_table "flight_records", :force => true do |t|
5
- t.date "date"
6
- t.datetime "created_at"
7
- t.datetime "updated_at"
8
- t.float "distance_estimate"
9
- t.integer "seats_estimate"
10
- t.float "load_factor"
11
- t.time "time_of_day"
12
- t.integer "year"
13
- t.integer "emplanements_per_trip"
14
- t.integer "trips"
15
- t.string "origin_airport_id"
16
- t.string "destination_airport_id"
17
- t.string "distance_class_id"
18
- t.string "aircraft_id"
19
- t.string "aircraft_class_id"
20
- t.string "propulsion_id"
21
- t.string "fuel_type_id"
22
- t.string "airline_id"
23
- t.string "seat_class_id"
24
- t.string "domesticity_id"
25
- end
26
- end