aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/chouette/journey_pattern.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/chouette/journey_pattern.rb')
-rw-r--r--app/models/chouette/journey_pattern.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/models/chouette/journey_pattern.rb b/app/models/chouette/journey_pattern.rb
index 1ddf7c9fb..53ff363a2 100644
--- a/app/models/chouette/journey_pattern.rb
+++ b/app/models/chouette/journey_pattern.rb
@@ -150,5 +150,23 @@ module Chouette
def costs
read_attribute(:costs) || {}
end
+
+ def costs_between start, finish
+ key = "#{start.id}-#{finish.id}"
+ costs[key]&.symbolize_keys || {}
+ end
+
+ def full_schedule?
+ full = true
+ stop_points.inject(nil) do |start, finish|
+ next finish unless start.present?
+ costs = costs_between(start, finish)
+ full = false unless costs.present?
+ full = false unless costs[:distance] && costs[:distance] > 0
+ full = false unless costs[:time] && costs[:time] > 0
+ finish
+ end
+ full
+ end
end
end