diff options
| author | Zakaria BOUZIANE | 2014-11-24 09:25:59 +0100 |
|---|---|---|
| committer | Zakaria BOUZIANE | 2014-11-24 09:25:59 +0100 |
| commit | 05e441cf7841a61e40a01a783d1b4f2fb0cd1a68 (patch) | |
| tree | d0bd95d1278e9fbacb033af218695409fb0bfeb3 /app/exporters | |
| parent | 3d61c788b87c8a4017dc86c4f2bc211fc784af14 (diff) | |
| download | chouette-core-05e441cf7841a61e40a01a783d1b4f2fb0cd1a68.tar.bz2 | |
HUB Export only if less than 50000 VehicleJourneyAtStops and start_date and end_date are provided
Diffstat (limited to 'app/exporters')
| -rw-r--r-- | app/exporters/chouette/hub/exporter.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/exporters/chouette/hub/exporter.rb b/app/exporters/chouette/hub/exporter.rb index 58454a0cb..27ac4e7ee 100644 --- a/app/exporters/chouette/hub/exporter.rb +++ b/app/exporters/chouette/hub/exporter.rb @@ -42,6 +42,10 @@ class Chouette::Hub::Exporter end end + def referential_exportable? + Chouette::VehicleJourneyAtStop.all.count < 50000 + end + def time_tables_exportable? time_tables end @@ -71,10 +75,12 @@ class Chouette::Hub::Exporter def export(zip_file_path, options = {}) begin referential.switch + + if referential_exportable? && options[:start_date] && options[:end_date] - FileUtils.rm(zip_file_path) if File.exists? zip_file_path + FileUtils.rm(zip_file_path) if File.exists? zip_file_path - hub_export.log_messages.create( :severity => "ok", :key => "EXPORT", :arguments => {"0" => "HUB"}) + hub_export.log_messages.create( :severity => "ok", :key => "EXPORT", :arguments => {"0" => "HUB"}) Dir.mktmpdir(nil, "/tmp"){ |temp_dir| @@ -239,6 +245,7 @@ class Chouette::Hub::Exporter end end } + end ensure # Always cleanup files #FileUtils.remove_entry(temp_directory) |
