diff options
| author | Teddy Wing | 2017-05-04 15:55:42 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-05-04 17:10:14 +0200 | 
| commit | 8978ffb9e346d35176371ef7d7879c8e41e96a97 (patch) | |
| tree | dae30be32b4355b85935df22d046d4ad453cd7af /app/models/chouette | |
| parent | 4c12a6632907d5d24b654791db994bfb830c7e37 (diff) | |
| download | chouette-core-8978ffb9e346d35176371ef7d7879c8e41e96a97.tar.bz2 | |
VehicleJourney: Add #with_stops
A new method that does the same thing as the query in
`VehicleJourneysController#collection`
(4c12a6632907d5d24b654791db994bfb830c7e37). The goal is to replace the
controller query code with this method so that it can be unit tested.
Refs #3268
Diffstat (limited to 'app/models/chouette')
| -rw-r--r-- | app/models/chouette/vehicle_journey.rb | 13 | 
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb index 4d7d596d8..297e462f0 100644 --- a/app/models/chouette/vehicle_journey.rb +++ b/app/models/chouette/vehicle_journey.rb @@ -209,5 +209,18 @@ module Chouette        end      end +    def self.with_stops +      self +        .joins(:journey_pattern) +        .joins(' +          LEFT JOIN "vehicle_journey_at_stops" +            ON "vehicle_journey_at_stops"."vehicle_journey_id" = +              "vehicle_journeys"."id" +            AND "vehicle_journey_at_stops"."stop_point_id" = +              "journey_patterns"."departure_stop_point_id" +        ') +        .order("vehicle_journey_at_stops.departure_time") +    end +    end  end  | 
