diff options
| author | Teddy Wing | 2018-02-01 12:40:09 +0100 |
|---|---|---|
| committer | cedricnjanga | 2018-02-06 11:10:19 -0800 |
| commit | 0df4fa90c1365fab181e864ea751b6d7b6894a88 (patch) | |
| tree | 8000aee8fee201e6771698e06f6b7ce3d7353ab0 | |
| parent | 57d8808a835dda23baaeaa41e800748d8faa028e (diff) | |
| download | chouette-core-0df4fa90c1365fab181e864ea751b6d7b6894a88.tar.bz2 | |
VehicleJourney.lines: Change query to only get lines for route
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.rb | 3 |
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 |
