aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorXinhui2017-06-28 15:28:35 +0200
committerXinhui2017-06-28 15:28:41 +0200
commitd704f6433672dbdddc1bdad9ed9bb48a61aaa00b (patch)
tree7b8bf12195634f6ad6a70b723f9c34e9d5316ed5 /app
parentf64246b8272a35731b3edba243b8d8e1898df1de (diff)
downloadchouette-core-d704f6433672dbdddc1bdad9ed9bb48a61aaa00b.tar.bz2
Fix cleanup should only destroy vj without any time_table
Refs #3917
Diffstat (limited to 'app')
-rw-r--r--app/models/clean_up.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/clean_up.rb b/app/models/clean_up.rb
index a791065aa..e39928a17 100644
--- a/app/models/clean_up.rb
+++ b/app/models/clean_up.rb
@@ -19,6 +19,7 @@ class CleanUp < ActiveRecord::Base
result['time_table'] = send("destroy_time_tables_#{self.date_type}").try(:count)
result['time_table_date'] = send("destroy_time_tables_dates_#{self.date_type}").try(:count)
result['time_table_period'] = send("destroy_time_tables_periods_#{self.date_type}").try(:count)
+ result['vehicle_journey'] = destroy_vehicle_journey_without_time_table.try(:count)
self.overlapping_periods.each do |period|
exclude_dates_in_overlapping_period(period)
end
@@ -100,9 +101,16 @@ class CleanUp < ActiveRecord::Base
end
end
+ def destroy_vehicle_journey_without_time_table
+ Chouette::VehicleJourney.without_any_time_table.destroy_all
+ end
+
def destroy_time_tables(time_tables)
+ # Delete vehicle_journey time_table association
time_tables.each do |time_table|
- time_table.vehicle_journeys.map(&:destroy)
+ time_table.vehicle_journeys.each do |vj|
+ vj.time_tables.delete(time_table)
+ end
end
time_tables.destroy_all
end