fossil 0.5.46 → 0.5.47
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/fossil.gemspec +2 -2
- data/lib/models/flight_log_expense.rb +14 -17
- data/lib/models/trip_leg.rb +11 -1
- data/lib/sequel/model_patch.rb +36 -31
- data/spec/sequel/model_patch_spec.rb +3 -0
- data/spec/temp_spec.rb +12 -7
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.47
|
data/fossil.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fossil}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.47"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Sudol", "Patrick Lardin"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-23}
|
13
13
|
s.description = %q{Access FOS/betrieve db with this Sequel based orm wrapper}
|
14
14
|
s.email = %q{dansudol@yahoo.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -4,7 +4,7 @@ class FlightLogExpense < Sequel::Model(:'flight log expenses')
|
|
4
4
|
|
5
5
|
#Many to one association with composite keys
|
6
6
|
n_to_o :trip_leg, :class=>:TripLeg, :prefix=>'trip leg'
|
7
|
-
many_to_one :vendor, :class=>:Vendor, :key=>:
|
7
|
+
many_to_one :vendor, :class=>:Vendor, :key=>:'vendor id', :primary_key=>:'vendor id'
|
8
8
|
|
9
9
|
#### BEGIN GENERATED SECTION ####
|
10
10
|
set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
|
@@ -118,7 +118,6 @@ class FlightLogExpense < Sequel::Model(:'flight log expenses')
|
|
118
118
|
act_str = "DEPT"
|
119
119
|
prefix = "FUELER"
|
120
120
|
end
|
121
|
-
use_leg = @trip_leg or trip_leg
|
122
121
|
|
123
122
|
sql = <<-SQL
|
124
123
|
SELECT TOP 1 TL."TRIP NUMBER",TL."LEG NUMBER", TL."#{ap_str} AIRPORT ID",
|
@@ -136,7 +135,7 @@ class FlightLogExpense < Sequel::Model(:'flight log expenses')
|
|
136
135
|
AND (TL."TRIP NUMBER" = ? AND TL."LEG NUMBER" = ?)
|
137
136
|
ORDER BY AF."EFFECTIVE DATE" DESC
|
138
137
|
SQL
|
139
|
-
return db.fetch(sql,
|
138
|
+
return db.fetch(sql, trip_leg.trip_number, trip_leg.leg_number).first
|
140
139
|
end
|
141
140
|
|
142
141
|
def build_fuel_tier_hash airport_fuel # creates a hash table of the qty and fuel prices for each tier
|
@@ -157,26 +156,24 @@ class FlightLogExpense < Sequel::Model(:'flight log expenses')
|
|
157
156
|
0.0
|
158
157
|
end
|
159
158
|
|
160
|
-
|
161
|
-
def fuel_passdown_hash the_trip_leg
|
159
|
+
def fuel_passdown_hash
|
162
160
|
expense_type = type_string
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
airport =
|
168
|
-
fbo =
|
169
|
-
|
170
|
-
leg_date = (@trip_leg.dept_date_act_local and @trip_leg.dept_date_act_local != 0 ? @trip_leg.dept_date_act_local : @trip_leg.depart_date_local)
|
161
|
+
leg = trip_leg
|
162
|
+
vendor_name = vendor__company_2
|
163
|
+
vendor_name = vendor__company_1 if !vendor_name or vendor_name == ""
|
164
|
+
vendor_name = vendor__vendor_id if !vendor_name or vendor_name == ""
|
165
|
+
airport = leg.send("#{expense_type}_icao_val")
|
166
|
+
fbo = leg.send("#{expense_type}_fbo__name")
|
167
|
+
leg_date = (leg.dept_date_act_local and leg.dept_date_act_local != 0 ? leg.dept_date_act_local : leg.depart_date_local)
|
171
168
|
|
172
169
|
{
|
173
170
|
:leg_date => leg_date,
|
174
|
-
:trip_number =>
|
175
|
-
:leg_number =>
|
176
|
-
:ac =>
|
171
|
+
:trip_number => leg.trip_number,
|
172
|
+
:leg_number => leg.leg_number,
|
173
|
+
:ac => leg.aircraft_id,
|
177
174
|
:airport => airport,
|
178
175
|
:fbo => fbo,
|
179
|
-
:vendor =>
|
176
|
+
:vendor => vendor_name,
|
180
177
|
:fuel_rate => fuel_rate,
|
181
178
|
:fuel_quantity => quantity,
|
182
179
|
:fuel_cost => fuel_cost
|
data/lib/models/trip_leg.rb
CHANGED
@@ -951,6 +951,16 @@ class TripLeg < Sequel::Model(:'trip legs')
|
|
951
951
|
filter(~{:'leg state' => 5}).
|
952
952
|
filter({:'dept date act local' => start_date..end_date,
|
953
953
|
:'depart date - local' => start_date...end_date}.sql_or).all
|
954
|
+
# eager_graph(:flight_log_expenses => :vendor).
|
955
|
+
# eager_graph(:departure_fbo).
|
956
|
+
# eager_graph(:arrival_fbo).
|
957
|
+
# select_fields(:self => [:dept_date_act_local, :depart_date_local, :trip_number, :leg_number,
|
958
|
+
# :departure_icao, :depart_ap_prefix, :depart_airport_id, :arrival_icao,
|
959
|
+
# :arrival_airport_id, :arrival_ap_prefix, :aircraft_id],
|
960
|
+
# :flight_log_expenses__vendor => [:company_2, :company_1, :vendor_id],
|
961
|
+
# :flight_log_expenses => [:*],
|
962
|
+
# :departure_fbo => [:name],
|
963
|
+
# :arrival_fbo => [:name]).all
|
954
964
|
end
|
955
965
|
|
956
966
|
def fuel_data_by_fbo_keys trip_legs, fbo_keys
|
@@ -961,7 +971,7 @@ class TripLeg < Sequel::Model(:'trip legs')
|
|
961
971
|
fbo_name = leg.send( "#{expense.type_string}_fbo__name" )
|
962
972
|
|
963
973
|
if fbo_keys.include?(fbo_name) then # is this an fbo we are looking for?
|
964
|
-
expense_hash = expense.fuel_passdown_hash
|
974
|
+
expense_hash = expense.fuel_passdown_hash
|
965
975
|
|
966
976
|
if data.has_key?(fbo_name)
|
967
977
|
data[fbo_name].push(expense_hash)
|
data/lib/sequel/model_patch.rb
CHANGED
@@ -259,39 +259,44 @@ class Sequel::Model
|
|
259
259
|
end
|
260
260
|
|
261
261
|
method_view_name = method_name.to_s + "_view"
|
262
|
+
case type
|
263
|
+
when :boolean, :currency, :precision
|
264
|
+
inst_def method_view_name do
|
265
|
+
value = send(method_name)
|
266
|
+
value.to_s if value
|
267
|
+
end
|
262
268
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
269
|
+
when :time
|
270
|
+
inst_def method_view_name do
|
271
|
+
value = send(method_name)
|
272
|
+
value.strftime('%H:%M') if value
|
273
|
+
end
|
274
|
+
|
275
|
+
when :date
|
276
|
+
inst_def method_view_name do
|
277
|
+
value = send(method_name)
|
278
|
+
value.to_s if value
|
279
|
+
end
|
280
|
+
|
281
|
+
# extra view methods for date type
|
282
|
+
method_view_name = method_name.to_s + "_view_mdy"
|
283
|
+
# method that returns the column value as a Date in mdy format
|
284
|
+
inst_def method_view_name do
|
285
|
+
column_value = send(column_name)
|
286
|
+
return nil unless column_value
|
287
|
+
Date.from_fos_days(column_value).strftime('%m/%d/%Y')
|
288
|
+
end
|
289
|
+
method_view_name = method_name.to_s + "_view_mdy_ipc"
|
290
|
+
# method that returns the column value as a Date in mdy format
|
291
|
+
inst_def method_view_name do
|
292
|
+
column_value = send(column_name)
|
293
|
+
return nil unless column_value
|
294
|
+
date_str = Date.from_fos_days(column_value).strftime('%m/%d/%Y')
|
295
|
+
date_str.slice!(3) if date_str[3] == 48 # if the fourth char is 0 ( ascii value 48 ) remove it
|
296
|
+
date_str.slice!(0) if date_str[0] == 48 # if the first char is 0 ( ascii value 48 ) remove it
|
297
|
+
date_str
|
298
|
+
end
|
293
299
|
end
|
294
|
-
end
|
295
300
|
end
|
296
301
|
|
297
302
|
def select_fields(table, * fields)
|
@@ -139,8 +139,11 @@ describe "Sequel::Model extentions" do
|
|
139
139
|
@record.should respond_to(:time_col_time)
|
140
140
|
@record.should respond_to(:time_col_time_view)
|
141
141
|
@record.should respond_to(:price_currency)
|
142
|
+
@record.should respond_to(:price_currency_view)
|
142
143
|
@record.should respond_to(:price_precision)
|
144
|
+
@record.should respond_to(:price_precision_view)
|
143
145
|
@record.should respond_to(:paid_boolean)
|
146
|
+
@record.should respond_to(:paid_boolean_view)
|
144
147
|
@record.should respond_to(:my_special_name)
|
145
148
|
end
|
146
149
|
|
data/spec/temp_spec.rb
CHANGED
@@ -1,18 +1,23 @@
|
|
1
|
-
|
1
|
+
require_relative '../spec_dbr/spec_helper'
|
2
|
+
#require 'spec_helper'
|
2
3
|
|
3
4
|
describe "FOS Licensing" do
|
4
5
|
before :all do
|
5
|
-
# set_fos_db([
|
6
|
-
# set_dbr_db([TripLeg, FlightLogExpense, Aircraft])
|
7
|
-
db = Sequel.
|
6
|
+
# set_fos_db([TripLeg, FlightLogExpense, Vendor, AirportFbo])
|
7
|
+
# set_dbr_db([TripLeg, FlightLogExpense, Aircraft, Vendor, AirportFbo])
|
8
|
+
db = Sequel.fos_dbr(:username => 'datamart', :password => 'datap@ss', :adapter => 'mysql', :host => 'hrkdm', :database => 'dbr')
|
8
9
|
db.loggers=[Logger.new($stdout)]
|
9
|
-
TripLeg.db = db
|
10
|
-
FlightLogExpense.db = db
|
10
|
+
[TripLeg, FlightLogExpense, Aircraft, Vendor, AirportFbo, AirportFuel].each { |m| m.db = db }
|
11
11
|
end
|
12
12
|
|
13
13
|
it "puts the lotion on the skin" do
|
14
|
-
|
14
|
+
legs = TripLeg.fuel_passdown_data(Date.parse('2011-02-06'), Date.parse('2011-02-06'), ["SIGNATURE FLIGHT SUPPORT"])
|
15
|
+
p "BLAH BLAH BLAH"
|
16
|
+
pp legs
|
15
17
|
|
18
|
+
# l = TripLeg.filter(:'trip number' => 68562, :'leg number' => 1).eager_graph(:flight_log_expenses => :vendor).all.first
|
19
|
+
# p "BLAH BLAH BLAH BLAH"
|
20
|
+
# p l.fuel_expenses.first.vendor
|
16
21
|
# p FlightLogExpense.where(:trip_leg_id => "SEMJ-3-17-39922-1258", :type => 1)
|
17
22
|
|
18
23
|
# tl = TripLeg.filter(:trip_number=>68562, :leg_number =>1).first
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: fossil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.47
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Daniel Sudol
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-03-
|
14
|
+
date: 2011-03-23 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|