aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks
diff options
context:
space:
mode:
authorZog2018-03-05 15:19:30 +0100
committerZog2018-03-05 15:19:30 +0100
commit2b1a8cdc047cd80108ac4c5ef1fd2a64d77ab750 (patch)
treea4c044bc9fc28e8afcd88741aad6da5b9ecb90d1 /lib/tasks
parenteb01c9180419f05ab0ad4a734c082cc889792e75 (diff)
downloadchouette-core-2b1a8cdc047cd80108ac4c5ef1fd2a64d77ab750.tar.bz2
Refs #6068; Fully functional JSON exporter
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/exports.rake30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/tasks/exports.rake b/lib/tasks/exports.rake
index 8688611e8..547388b35 100644
--- a/lib/tasks/exports.rake
+++ b/lib/tasks/exports.rake
@@ -43,7 +43,7 @@ namespace :export do
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.parameterize}_#{Time.now.strftime "%y%m%d%H%M"}", logs_output_dir: "./log/exporters/", timelapse: 90)
+ args.with_defaults(output_dir: "#{referential.name.parameterize}/#{Time.now.strftime "%y%m%d%H%M"}", logs_output_dir: "./log/exporters/", timelapse: 90)
referential.switch
@@ -51,44 +51,44 @@ namespace :export do
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 = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_companies", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_companies.json"
+ ids = journeys.pluck :company_id
+ ids += journeys.joins(route: :line).pluck :"lines.company_id"
+
exporter.configure do |config|
- config.collection = journeys
+ config.collection = Chouette::Company.where(id: ids.uniq).order('name')
end
SimpleInterfacesHelper.run_interface_controlling_interruption exporter, :export, args
- return unless exporter.status == :success
+ break if exporter.status == :error
- exporter = SimpleExporter.create configuration_name: "#{args[:configuration_name]}_schedules", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_schedules.csv"
+ exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_schedules", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_schedules.json"
exporter.configure do |config|
config.collection = journeys
end
SimpleInterfacesHelper.run_interface_controlling_interruption exporter, :export, args
- return unless exporter.status == :success
+ break if exporter.status == :error
- exporter = SimpleExporter.create configuration_name: "#{args[:configuration_name]}_routes", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_routes.csv"
+ exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_routes", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_routes.json"
exporter.configure do |config|
config.collection = Chouette::JourneyPattern.where(id: journeys.pluck(:journey_pattern_id).uniq)
end
SimpleInterfacesHelper.run_interface_controlling_interruption exporter, :export, args
- return unless exporter.status == :success
+ break if exporter.status == :error
- exporter = SimpleExporter.create configuration_name: "#{args[:configuration_name]}_stops", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_stops.csv"
+ exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_stops", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_stops.json"
exporter.configure do |config|
config.collection = Chouette::StopArea.where(id: journeys.joins(:stop_points).pluck(:"stop_points.stop_area_id").uniq).order('parent_id ASC NULLS FIRST')
end
SimpleInterfacesHelper.run_interface_controlling_interruption exporter, :export, args
- return unless exporter.status == :success
-
- exporter = SimpleExporter.create configuration_name: "#{args[:configuration_name]}_companies", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_companies.csv"
- ids = journeys.pluck :company_id
- ids += journeys.joins(route: :line).pluck :"lines.company_id"
+ break if exporter.status == :error
+ exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_journeys", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_journeys.json"
exporter.configure do |config|
- config.collection = Chouette::Company.where(id: ids.uniq).order('name')
+ config.collection = journeys
end
SimpleInterfacesHelper.run_interface_controlling_interruption exporter, :export, args