aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-02-01 12:40:09 +0100
committercedricnjanga2018-02-06 11:10:19 -0800
commit0df4fa90c1365fab181e864ea751b6d7b6894a88 (patch)
tree8000aee8fee201e6771698e06f6b7ce3d7353ab0
parent57d8808a835dda23baaeaa41e800748d8faa028e (diff)
downloadchouette-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.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