diff options
| author | Teddy Wing | 2018-05-14 12:41:27 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2018-05-14 12:41:27 +0200 | 
| commit | 84683c111e16e19c94a71f36f1d66c0745ad33d8 (patch) | |
| tree | 6f2672dec257ffcd940442f8d815293bc9c270e4 /app/models | |
| parent | 4c94257d93c33bc2d6a2c4f146ebe0843763c89a (diff) | |
| download | chouette-core-84683c111e16e19c94a71f36f1d66c0745ad33d8.tar.bz2 | |
CleanUp: Add `#destroy_routes_outside_referential`
This builds on `#destroy_vehicle_journeys_outside_referential` (which
will soon be removed in favour of this new method).
It destroys orphaned routes in a referential.
Refs #6854
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/clean_up.rb | 5 | 
1 files changed, 5 insertions, 0 deletions
| diff --git a/app/models/clean_up.rb b/app/models/clean_up.rb index 0f73e07b2..cf8908263 100644 --- a/app/models/clean_up.rb +++ b/app/models/clean_up.rb @@ -105,6 +105,11 @@ class CleanUp < ApplicationModel      Chouette::VehicleJourney.joins(:route).where(["routes.line_id not in (?)", line_ids]).destroy_all    end +  def destroy_routes_outside_referential +    line_ids = referential.metadatas.pluck(:line_ids).flatten.uniq +    Chouette::Route.where(['line_id not in (?)', line_ids]).destroy_all +  end +    def destroy_vehicle_journeys      Chouette::VehicleJourney.where("id not in (select distinct vehicle_journey_id from time_tables_vehicle_journeys)").destroy_all    end | 
