fossil 0.5.12 → 0.5.13

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.12
1
+ 0.5.13
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.12"
8
+ s.version = "0.5.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Patrick Lardin, Daniel Sudol"]
12
- s.date = %q{2010-10-29}
12
+ s.date = %q{2010-11-15}
13
13
  s.description = %q{Access FOS/betrieve db with this Sequel based orm wrapper}
14
14
  s.email = %q{plardin@xojet.com}
15
15
  s.extra_rdoc_files = [
@@ -125,4 +125,20 @@ class CrewDuty < Sequel::Model(:'crew duty')
125
125
  column_alias :key7, :'key7'
126
126
  #### END GENERATED SECTION ####
127
127
 
128
+ column_def_datetime :duty_start_time, :'act begin date home', :'act begin time home'
129
+ column_def_datetime :duty_end_time, :'act end date home', :'act end time home'
130
+
131
+ # Fetches the crew duty records in a given interval
132
+ def self.find_crew_duty_in_time_range(from_datetime, to_datetime)
133
+ # Fetching the records verified or amended in the time interval passed in
134
+ crew_duties=CrewDuty.filter(
135
+ {:verified=>1, :amended=>0, :verified_date=>from_datetime.to_fos_days, :verified_time=>(from_datetime.as_minutes..1440)} |
136
+ {:verified=>1, :amended=>0, :verified_date=>to_datetime.to_fos_days, :verified_time=>(0..to_datetime.as_minutes)} |
137
+ {:verified=>1, :amended=>1, :amended_date=>from_datetime.to_fos_days, :amended_time=>(from_datetime.as_minutes..1440)} |
138
+ {:verified=>1, :amended=>1, :amended_date=>to_datetime.to_fos_days, :amended_time=>(0..to_datetime.as_minutes)}
139
+ ).all
140
+
141
+ # Extracting the meaningful values from the result set
142
+ crew_duties.collect {|crew_duty| crew_duty.fill_hash([:employee_id,:duty_start_time,:duty_end_time]) }
143
+ end
128
144
  end
data/spec/silly_spec.rb CHANGED
@@ -1,26 +1,48 @@
1
1
  require 'fossil'
2
2
  require 'logger'
3
3
 
4
- DB = Sequel.fos('flyos', :loggers=>[Logger.new($stdout)])
5
- [Trip,TripLeg].each{|m| m.db=DB}
4
+ DB = Sequel.fos('fosprod', :loggers=>[Logger.new($stdout)])
5
+ [Passenger,CrewDuty].each{|m| m.db=DB}
6
+ #[Trip,CrewTrip,TripLeg,TripPassenger,Passenger,CrewLeg].each{|m| m.db=DB}
6
7
  #[Trip,TripLeg,Airport,AirportFbo,Aircraft,CrewLeg,Code,TripPassenger,Passenger,Personnel,Quote,Comment].each{|m| m.db=DB}
7
- start_date = Date.parse('July 1 2010').to_fos_days
8
- end_date = Date.parse('Aug 31 2010').to_fos_days
9
- #p [start_date, end_date]
10
- #p TripLeg.filter(:depart_date_key=> (start_date..end_date) ).count
11
- #p Trip.filter(:departure_date_gmt=> (start_date..end_date) ).count
12
- #t = TripLeg["PHIP", 0, 17, 40257, 974]
13
- #t.update(:kid_date=>40256)
14
- #t.update(:kid_date => 40247)
8
+ #start_date = Date.parse('June 15 2010').to_fos_days
9
+ #end_date = Date.parse('July 1 2010').to_fos_days
10
+ #p TripLeg.filter{ kid_date > start_date}.count
11
+ #tl = TripLeg.filter(:trip_number=>79174, :leg_number=>1 ).first
12
+ #t = tl.trip
13
+ #p t.kid_date
14
+ #p tl.kid_date
15
+ #p t.crew_trips.collect &:kid_date
15
16
 
16
- def diff_hash(arr)
17
- Hash[*arr.collect{|v|[v[0],v[1]]}.flatten]
18
- end
17
+ #p TripLeg.filter{ kid_date > end_date}.limit(10).all.collect{|tl| [tl.kid_date,(tl.trip.kid_date)]}
18
+ #p TripLeg.filter{ kid_date > end_date}.limit(10).all.collect{|tl| [tl.status,tl.trip__passengers.collect(&:kid_date)] }
19
19
 
20
- old_attrs = {:dan=>'cool',:jade=>'nice'}
21
- new_attrs = {:dan=>'cool',:jade=>'there'}
22
- old_diffs=diff_hash(old_attrs.to_a-new_attrs.to_a)
23
- new_diffs=diff_hash(new_attrs.to_a-old_attrs.to_a)
24
- old_diffs.each{|k,v| old_diffs[k] = [v,new_diffs[k]] if new_diffs[k] }
20
+ #tl = TripLeg.filter((:kid_date + 0) > end_date,:status=>1 ).first
21
+ #p tl.kid_date
22
+ #p tl.trip.kid_date
23
+ #p tl.trip.trip_passengers.collect &:kid_date
25
24
 
25
+ #p Passenger.filter(:pax_is_a_requester=>1).count
26
26
 
27
+ #now = Date.today.to_gm_time
28
+ #from_datetime = now - 1.day + 1.minute
29
+ #to_datetime = now
30
+ #duty_periods = CrewDuty.find_crew_duty_in_time_range(from_datetime, to_datetime)
31
+ #p duty_periods
32
+
33
+ #p Trip.filter{ kid_date < start_date}.delete
34
+ #p TripLeg.filter{ trips_kid_date < start_date}.delete
35
+ #p TripPassenger.filter{ trip_kid_date < start_date}.delete
36
+ #sql = <<SQL
37
+ #delete cl
38
+ # from "crew legs" cl inner join "crew trips" ct on
39
+ # cl."crew trip kid - date" = ct."kid - date" and
40
+ # cl."crew trip kid - time" = ct."kid - time" and
41
+ # cl."crew trip kid - user" = ct."kid - user" and
42
+ # cl."crew trip kid - comm" = ct."kid - comm" and
43
+ # cl."crew trip kid - mult" = ct."kid - mult" and
44
+ # ct."trip kid - date" < #{start_date};
45
+ #SQL
46
+ #p DB.execute(sql)
47
+ #p CrewLeg.count
48
+ #p CrewTrip.filter{ trip_kid_date < start_date}.delete
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 12
9
- version: 0.5.12
8
+ - 13
9
+ version: 0.5.13
10
10
  platform: ruby
11
11
  authors:
12
12
  - Patrick Lardin, Daniel Sudol
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-29 00:00:00 -07:00
17
+ date: 2010-11-15 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency