From dbcd099b3d38f7c584450edffc8bee0a2502b170 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 13 Mar 2018 15:37:55 +0100 Subject: Route: Add `#calculate_costs!` to populate `#costs` with `WayCost`s This new method will launch a worker that takes the route's `StopArea`s, converts them to `WayCost`s, sends them to the TomTom API to calculate distance and time costs, and saves those costs to the route's `costs` field. Refs #6095 --- app/workers/route_way_cost_worker.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 app/workers/route_way_cost_worker.rb (limited to 'app/workers') diff --git a/app/workers/route_way_cost_worker.rb b/app/workers/route_way_cost_worker.rb new file mode 100644 index 000000000..adb10957b --- /dev/null +++ b/app/workers/route_way_cost_worker.rb @@ -0,0 +1,8 @@ +class RouteWayCostWorker + include Sidekiq::Worker + + def perform(route_id) + route = Chouette::Route.find(route_id) + RouteWayCostCalculator.new(route).calculate! + end +end -- cgit v1.2.3