aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-02-01 12:40:09 +0100
committerTeddy Wing2018-02-01 15:42:04 +0100
commit7eab1a2999b5d993ec8ebf9655d52e278b88081d (patch)
tree4e95fc7e00f3c74a7c06ecdfab7619fd37a2e46a
parentf7317ff7a1e5cba9bec9a3ab5571699938924c57 (diff)
downloadchouette-core-7eab1a2999b5d993ec8ebf9655d52e278b88081d.tar.bz2
VehicleJourney.lines: Change query to only get lines for route5576-vehicle-journeys--filter-by-line
Johan recommended using an `IN` query to only get the lines in the current scope. I assumed I'd be covered by the schema and how only the lines for the current referential are in the schema, but this is probably a more reasonable way to get associated lines. Refs #5576
-rw-r--r--app/models/chouette/vehicle_journey.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb
index 30b8903a1..6146d5be8 100644
--- a/app/models/chouette/vehicle_journey.rb
+++ b/app/models/chouette/vehicle_journey.rb
@@ -377,7 +377,8 @@ module Chouette
end
def self.lines
- Chouette::Line.joins(routes: :vehicle_journeys).distinct
+ lines_query = joins(:route).select("routes.line_id").to_sql
+ Chouette::Line.where("id IN (#{lines_query})")
end
end
end