aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks/exports.rake
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks/exports.rake')
-rw-r--r--lib/tasks/exports.rake22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/tasks/exports.rake b/lib/tasks/exports.rake
index 036d96b11..6ff73dac0 100644
--- a/lib/tasks/exports.rake
+++ b/lib/tasks/exports.rake
@@ -40,8 +40,24 @@ namespace :export do
SimpleInterfacesHelper.run_interface_controlling_interruption exporter, :export, args
end
- desc "export a complete offer from the gicen referential in the given X next days"
- task :full_offer, [:referential_id, :timelapse, :configuration_name, :output_dir, :logs_output_dir] => :environment do |t, args|
- args.with_defaults(filepath: "./companies.csv", logs_output_dir: "./log/exporters/")
+ desc "export a complete offer from the given referential in the given X next days"
+ task :full_offer, [:referential_id, :configuration_name, :timelapse, :output_dir, :logs_output_dir] => :environment do |t, args|
+ referential = Referential.find args[:referential_id]
+ args.with_defaults(output_dir: referential.name, logs_output_dir: "./log/exporters/", timelapse: 90)
+
+ referential.switch
+
+ journeys = Chouette::VehicleJourney.with_matching_timetable (Time.now.to_date..args[:timelapse].to_i.days.from_now.to_date)
+ if journeys.count == 0
+ puts "No maching journeys were found".red
+ else
+
+ exporter = SimpleExporter.create configuration_name: "#{args[:configuration_name]}_journeys", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_journeys.csv"
+ exporter.configure do |config|
+ config.collection = journeys
+ end
+
+ SimpleInterfacesHelper.run_interface_controlling_interruption exporter, :export, args
+ end
end
end