]> jaekl.net Git - oct_sched.git/commitdiff
When counting trips, only count the trip for that route from the stop where it origin...
authorChris Jaekl <chris@localhost>
Tue, 14 Feb 2023 22:21:22 +0000 (17:21 -0500)
committerChris Jaekl <chris@localhost>
Tue, 14 Feb 2023 22:21:22 +0000 (17:21 -0500)
lib/gtfs.rb
lib/stats.rb

index 053f4828f9f5c5964e5a160679bbd5db09cd1659..17cfc27d690899b978f6f4591c13083c0dbd4d94 100644 (file)
@@ -85,12 +85,12 @@ class Gtfs
 
   private
 
-  def trips_for_stop_code(stop_code:, date_hash:)
+  def trips_for_stop_code(stop_code:, date_hash:, originating_only: false)
     stop_ids = @db.query("SELECT stop_id FROM stops WHERE stop_code=?", stop_code).to_a.map do |row|
       row.first
     end
 
-    trips_for_stop_ids(stop_ids: stop_ids, date_hash: date_hash)
+    trips_for_stop_ids(stop_ids: stop_ids, date_hash: date_hash, originating_only: originating_only)
   end
 
   def trips_for_stop_ids(stop_ids:, date_hash:, originating_only: false)
@@ -148,7 +148,7 @@ class Gtfs
     end.to_h
   end
 
-  def trips_for_stop_name(stop_name:, date_hash:)
+  def trips_for_stop_name(stop_name:, date_hash:, originating_only: false)
     result = {}
 
     base_name = stop_name.upcase
@@ -163,7 +163,7 @@ class Gtfs
       row.first
     end
 
-    trips_for_stop_ids(stop_ids: stop_ids, date_hash: date_hash)
+    trips_for_stop_ids(stop_ids: stop_ids, date_hash: date_hash, originating_only: originating_only)
   end
 
   def calendar
index 5811fe7dd5e3ad0c930dd85a531f451c67d99787..a67b57e5e5ddd882911983f8347ceea3189976c8 100644 (file)
@@ -66,7 +66,7 @@ class Stats
       print "."
       $stdout.flush
 
-      route_trips = @gtfs.trips(stop_id: stop_id, date_hash: date_hash).map do |k, v|
+      route_trips = @gtfs.trips(stop_id: stop_id, date_hash: date_hash, originating_only: true).map do |k, v|
         [
           k.first,
           v.map do |x|