aboutsummaryrefslogtreecommitdiffstats
path: root/app/workers
diff options
context:
space:
mode:
authorTeddy Wing2018-03-13 18:10:46 +0100
committerTeddy Wing2018-03-14 16:42:02 +0100
commit13135a5251f2af3e85bb2bb1be9866477b7414e9 (patch)
tree27538025e62f9a9e66b0e70fbc65ed7df26a27ce /app/workers
parent3fe9aad1d003814c2f5a5de834ce42a028df1753 (diff)
downloadchouette-core-13135a5251f2af3e85bb2bb1be9866477b7414e9.tar.bz2
RouteWayCostWorker: Fix recursive worker call
Since this method was run on `after_save` and in it `RouteWayCostCalculator` calls `#update` on the given route, it caused an infinite recursive call to the worker. To prevent this, wrap the `#calculate!` call in methods that unset and reset the callback. Refs #6095
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/route_way_cost_worker.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/workers/route_way_cost_worker.rb b/app/workers/route_way_cost_worker.rb
index fa5bd737d..2ec8cdff9 100644
--- a/app/workers/route_way_cost_worker.rb
+++ b/app/workers/route_way_cost_worker.rb
@@ -4,6 +4,11 @@ class RouteWayCostWorker
def perform(referential_id, route_id)
Referential.find(referential_id).switch
route = Chouette::Route.find(route_id)
+
+ Chouette::Route.skip_callback(:save, :after, :calculate_costs!)
+
RouteWayCostCalculator.new(route).calculate!
+
+ Chouette::Route.set_callback(:save, :after, :calculate_costs!)
end
end